summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/README12
-rw-r--r--examples/SQL/README76
-rw-r--r--examples/SQL/connect.ui238
-rw-r--r--examples/SQL/connect.ui.h21
-rwxr-xr-xexamples/SQL/dbconnect.py82
-rw-r--r--examples/SQL/dbpar.py22
-rw-r--r--examples/SQL/form1.ui77
-rw-r--r--examples/SQL/form2.ui327
-rw-r--r--examples/SQL/frmconnect.py120
-rw-r--r--examples/SQL/frmconnect.ui245
-rwxr-xr-xexamples/SQL/runform1.py21
-rwxr-xr-xexamples/SQL/runform2.py21
-rwxr-xr-xexamples/SQL/runsqlex.py151
-rwxr-xr-xexamples/SQL/sqlcustom1.py94
-rw-r--r--examples/SQL/sqlex.ui303
-rw-r--r--examples/SQL/sqlex.ui.h35
-rwxr-xr-xexamples/SQL/sqlsubclass5.py151
-rwxr-xr-xexamples/SQL/sqltable4.py118
-rw-r--r--examples/SQL/testdb_mysql.sql57
-rw-r--r--examples/SQL/testdb_pg.sql232
-rwxr-xr-xexamples/aclock.py61
-rwxr-xr-xexamples/addressbook.py457
-rwxr-xr-xexamples/application.py277
-rwxr-xr-xexamples/biff.py173
-rwxr-xr-xexamples/bigtable.py72
-rwxr-xr-xexamples/buttongroups.py125
-rw-r--r--examples/canvas/butterfly.pngbin0 -> 37832 bytes
-rwxr-xr-xexamples/canvas/canvas.py619
-rw-r--r--examples/canvas/qt-trans.xpm54
-rw-r--r--examples/canvas/qtlogo.pngbin0 -> 22603 bytes
-rwxr-xr-xexamples/checklists.py135
-rwxr-xr-xexamples/cursor.py114
-rwxr-xr-xexamples/dclock.py58
-rwxr-xr-xexamples/desktop.py230
-rwxr-xr-xexamples/dirview.py452
-rwxr-xr-xexamples/dragdrop.py57
-rwxr-xr-xexamples/drawlines.py74
-rw-r--r--examples/dropsite.py96
-rw-r--r--examples/fileopen.xpm22
-rwxr-xr-xexamples/fontdisplayer.py148
-rwxr-xr-xexamples/fonts.py149
-rwxr-xr-xexamples/gears.py235
-rw-r--r--examples/i18n/i18n.pro15
-rwxr-xr-xexamples/i18n/i18n.py147
-rw-r--r--examples/i18n/mywidget.py47
-rw-r--r--examples/i18n/mywidget_cs.qmbin0 -> 818 bytes
-rw-r--r--examples/i18n/mywidget_cs.ts75
-rw-r--r--examples/i18n/mywidget_de.qmbin0 -> 913 bytes
-rw-r--r--examples/i18n/mywidget_de.ts69
-rw-r--r--examples/i18n/mywidget_el.qmbin0 -> 832 bytes
-rw-r--r--examples/i18n/mywidget_el.ts68
-rw-r--r--examples/i18n/mywidget_en.qmbin0 -> 337 bytes
-rw-r--r--examples/i18n/mywidget_en.ts69
-rw-r--r--examples/i18n/mywidget_eo.qmbin0 -> 835 bytes
-rw-r--r--examples/i18n/mywidget_eo.ts72
-rw-r--r--examples/i18n/mywidget_fr.qmbin0 -> 884 bytes
-rw-r--r--examples/i18n/mywidget_fr.ts68
-rw-r--r--examples/i18n/mywidget_it.qmbin0 -> 763 bytes
-rw-r--r--examples/i18n/mywidget_it.ts72
-rw-r--r--examples/i18n/mywidget_jp.qmbin0 -> 738 bytes
-rw-r--r--examples/i18n/mywidget_jp.ts68
-rw-r--r--examples/i18n/mywidget_ko.qmbin0 -> 738 bytes
-rw-r--r--examples/i18n/mywidget_ko.ts68
-rw-r--r--examples/i18n/mywidget_no.qmbin0 -> 830 bytes
-rw-r--r--examples/i18n/mywidget_no.ts68
-rw-r--r--examples/i18n/mywidget_ru.qmbin0 -> 799 bytes
-rw-r--r--examples/i18n/mywidget_ru.ts68
-rw-r--r--examples/i18n/mywidget_zh.qmbin0 -> 706 bytes
-rw-r--r--examples/i18n/mywidget_zh.ts68
-rwxr-xr-xexamples/lineedits.py140
-rwxr-xr-xexamples/listbox.py176
-rwxr-xr-xexamples/listboxcombo.py167
-rw-r--r--examples/marble.pngbin0 -> 25239 bytes
-rwxr-xr-xexamples/mdi.py360
-rwxr-xr-xexamples/menu.py286
-rwxr-xr-xexamples/progress.py281
-rwxr-xr-xexamples/progressbar.py155
-rwxr-xr-xexamples/qdir.py324
-rwxr-xr-xexamples/qmag.py233
-rw-r--r--examples/qt.pngbin0 -> 355 bytes
-rw-r--r--examples/qtlogo.pngbin0 -> 12634 bytes
-rwxr-xr-xexamples/rangecontrols.py79
-rwxr-xr-xexamples/richtext.py136
-rw-r--r--examples/secret.py65
-rwxr-xr-xexamples/semaphore.py203
-rwxr-xr-xexamples/smalltable.py57
-rwxr-xr-xexamples/splitter.py65
-rwxr-xr-xexamples/tabdialog.py116
-rwxr-xr-xexamples/tablestatistics.py170
-rwxr-xr-xexamples/tooltip.py105
-rw-r--r--examples/trolltech.bmpbin0 -> 30055 bytes
-rw-r--r--examples/trolltech.gifbin0 -> 42629 bytes
-rw-r--r--examples/tt-logo.pngbin0 -> 3133 bytes
-rwxr-xr-xexamples/tut1.py16
-rwxr-xr-xexamples/tut10.py145
-rwxr-xr-xexamples/tut11.py213
-rwxr-xr-xexamples/tut12.py253
-rwxr-xr-xexamples/tut13.py330
-rwxr-xr-xexamples/tut14.py378
-rwxr-xr-xexamples/tut2.py19
-rwxr-xr-xexamples/tut3.py21
-rwxr-xr-xexamples/tut4.py29
-rwxr-xr-xexamples/tut5.py32
-rwxr-xr-xexamples/tut6.py41
-rwxr-xr-xexamples/tut7.py57
-rwxr-xr-xexamples/tut8.py97
-rwxr-xr-xexamples/tut9.py104
-rw-r--r--examples/webbrowser/mainwindow.py1097
-rw-r--r--examples/webbrowser/mainwindow.ui410
-rw-r--r--examples/webbrowser/webbrowser.py91
-rwxr-xr-xexamples/widgets.py500
111 files changed, 14004 insertions, 0 deletions
diff --git a/examples/README b/examples/README
new file mode 100644
index 0000000..fcebe5f
--- /dev/null
+++ b/examples/README
@@ -0,0 +1,12 @@
+To run these examples, make sure you have your PYTHONPATH environment variable
+set if needed and explicitly set the path to python at the top of each script
+if you don't have /usr/bin/env.
+
+The examples are written for TQt v3.x.
+
+A much better source of information about using PyTQt is Boudewijn Rempt's
+book at http://stage.linuxports.com/projects/pyqt/.
+
+
+Phil Thompson
+phil@riverbankcomputing.co.uk
diff --git a/examples/SQL/README b/examples/SQL/README
new file mode 100644
index 0000000..862e608
--- /dev/null
+++ b/examples/SQL/README
@@ -0,0 +1,76 @@
+This directory contains some translated sql examples from TQt 3.x.
+
+runform1.py, form1.ui:
+
+ A simple designer generated TQDataTable. Run "pyuic form1.ui -o form1.py".
+
+runform2.py, form2.ui:
+
+ A simple designer generated TQDataBrowser. Run "pyuic form2.ui -o form2.py".
+
+sqlcustom1.py:
+
+ TQSqlForm based form with a simple custom editor forcing all input to
+ be uppercase
+
+sqltable4.py:
+
+ Custom TQDataTable with reimplemented paintField method, combined with
+ a TQComboBox based custom field editor (StatusPicker), gathering its
+ items from a different table (status) and a calculated column (monsalary).
+ Note, that TQSqlEditorFactory based field editors are somewhat restricted,
+ because TQt's TQ_PROPERTY feature isn't supported, yet. I've circumvented
+ this limitation by choosing the status table ids corresponding to the
+ index in the TQComboBox.
+
+sqlsubclass5.py:
+
+ Similar to the former, and even more deviated from its qt ancestor,
+ because the sense escaped me. This could be related to the different
+ database layout needed for MySQL (Trolltech used PostgreSQL sequences,
+ while we're using the simpler, but less powerful auto_increment here).
+ If you enter and invalid date (e.g. day: 0) in the Paid column, it is
+ shown as "not yet", but produces some qt warnings.
+
+runsqlex.py, sqlex.ui, sqlex.ui.h, connect.ui, connect.ui.h:
+
+ This one is a most advanced example, showing the use of a TQSqlCursor
+ driven by TQSqlQuery and iterating through database tables and fields.
+ Definitely worth a look.
+
+Unfortunately you will have to make sure that these prerequisites are met
+before trying the examples:
+
+ - Install MySQL or PostgreSQL and any development packages
+
+ - Create a database user with sufficient rights
+
+ - Create the testdb database
+ - For MySQL, run: mysql -u user -p password < testdb_mysql.sql
+ - For PostgreSQL, run: psql -U user template1 -f testdb_pg.sql
+
+ - Build TQt with the mysql and/or psql modules activated.
+
+Now you should be ready for the fun part. You can run dbconnect.py from
+a command line and try to connect to the database. If all went well,
+'ok' should be printed after pressing OK. If you don't want to enter all
+your data over and over again, create a file named local_dbpar.py here,
+with the following keys (with your own data, of course):
+
+DB_HOSTNAMES = ["localhost"]
+DB_DATABASES = ["testdb"]
+DB_USERNAME = "name"
+DB_PASSWORD = "pass"
+
+The dbconnect.py script is generated from dbconnect.ui, which was created
+with qt's designer. You can find it also in Boudewijn Rempt's book
+"GUI Programming with Python, using the TQt Toolkit". Although you won't find
+the SQL widgets discussed there, for the simple reason of the book being
+written before they appeared, it is a valuable source for anybody new in
+this area.
+
+Please direct any comments, patches and questions to <pytde@mats.gmd.de>.
+
+Good luck
+
+Hans-Peter Jansen <hpj@urpla.net>
diff --git a/examples/SQL/connect.ui b/examples/SQL/connect.ui
new file mode 100644
index 0000000..d33a783
--- /dev/null
+++ b/examples/SQL/connect.ui
@@ -0,0 +1,238 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>ConnectDialog</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>ConnectDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>303</width>
+ <height>251</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Connect...</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>GroupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Connection settings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>editDatabase</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Database Name:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>comboDatabase</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="3" column="1">
+ <property name="name">
+ <cstring>editPassword</cstring>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>TextLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Username:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editUsername</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="3" column="0">
+ <property name="name">
+ <cstring>TextLabel4_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Password:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editPassword</cstring>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="0" column="1">
+ <property name="name">
+ <cstring>comboDriver</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>editUsername</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="4" column="1">
+ <property name="name">
+ <cstring>editHostname</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="4" column="0">
+ <property name="name">
+ <cstring>TextLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Hostname:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editHostname</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="5" column="0">
+ <property name="name">
+ <cstring>TextLabel5_2</cstring>
+ </property>
+ <property name="text">
+ <string>P&amp;ort:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>portSpinBox</cstring>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="5" column="1">
+ <property name="name">
+ <cstring>portSpinBox</cstring>
+ </property>
+ <property name="specialValueText">
+ <string>Default</string>
+ </property>
+ <property name="maxValue">
+ <number>65535</number>
+ </property>
+ <property name="minValue">
+ <number>-1</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>D&amp;river</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>comboDriver</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout25</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButton1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButton2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>PushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>ConnectDialog</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>PushButton2</sender>
+ <signal>clicked()</signal>
+ <receiver>ConnectDialog</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>comboDriver</tabstop>
+ <tabstop>editDatabase</tabstop>
+ <tabstop>editUsername</tabstop>
+ <tabstop>editPassword</tabstop>
+ <tabstop>editHostname</tabstop>
+ <tabstop>portSpinBox</tabstop>
+ <tabstop>PushButton1</tabstop>
+ <tabstop>PushButton2</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">connect.ui.h</include>
+</includes>
+<slots>
+ <slot>init()</slot>
+ <slot>destroy()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/connect.ui.h b/examples/SQL/connect.ui.h
new file mode 100644
index 0000000..ceff8dc
--- /dev/null
+++ b/examples/SQL/connect.ui.h
@@ -0,0 +1,21 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename slots use TQt Designer which will
+** update this file, preserving your code. Create an init() slot in place of
+** a constructor, and a destroy() slot in place of a destructor.
+*****************************************************************************/
+
+
+void ConnectDialog::init()
+{
+from python_tqt.qtsql import TQSqlDatabase
+#qDebug("ConnectDialog init")
+self.comboDriver.clear()
+self.comboDriver.insertStringList(TQSqlDatabase.drivers())
+}
+
+void ConnectDialog::destroy()
+{
+
+}
diff --git a/examples/SQL/dbconnect.py b/examples/SQL/dbconnect.py
new file mode 100755
index 0000000..d1c1baf
--- /dev/null
+++ b/examples/SQL/dbconnect.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from frmconnect import frmConnect
+from dbpar import *
+
+TRUE = 1
+FALSE = 0
+
+def createConnection():
+ driver = DB_DRIVER
+ # all qt examples use TQSqlDatabase::addDatabase, but
+ # this never returns NULL in my experience
+ drivers = list(map(str, TQSqlDatabase.drivers()))
+ if driver in drivers:
+ dlg = dbConnect(driver)
+ #TODO: make connection parameters accessible
+ return dlg.exec_loop()
+ else:
+ TQMessageBox.warning(None, "Database Error",
+ "<%s> database driver not found!\n\n"
+ "Please make sure, that this database adaptor\n"
+ "is available in your TQt installation.\n" %
+ (driver), TQMessageBox.Abort | TQMessageBox.Escape)
+ return FALSE
+
+class dbConnect(frmConnect):
+ def __init__(self, driver, parent = None):
+ frmConnect.__init__(self, parent)
+ self.hostnames = DB_HOSTNAMES
+ self.hostname = DB_HOSTNAMES[0]
+ self.databases = DB_DATABASES
+ self.database = DB_DATABASES[0]
+ self.username = DB_USERNAME
+ self.password = DB_PASSWORD
+ self.dbdriver = driver
+
+ self.txtName.setText(self.username)
+ self.txtPasswd.setText(self.password)
+ list(map(self.cmbServer.insertItem, self.hostnames))
+ list(map(self.cmbDatabase.insertItem, self.databases))
+ self.connect(self.buttonHelp, SIGNAL("clicked()"),
+ self.buttonHelp_clicked)
+
+ def accept(self):
+ self.hostname = self.cmbServer.currentText()
+ self.database = self.cmbDatabase.currentText()
+ self.username = self.txtName.text()
+ self.password = self.txtPasswd.text()
+ db = TQSqlDatabase.addDatabase(self.dbdriver)
+ if db:
+ db.setHostName(self.hostname)
+ db.setDatabaseName(self.database)
+ db.setUserName(self.username)
+ db.setPassword(self.password)
+ if db.open():
+ frmConnect.accept(self)
+ else:
+ TQMessageBox.warning(self, "Database Error",
+ "Cannot open %s database on %s!\n\n%s\n%s\n" %
+ (self.database, self.hostname,
+ db.lastError().driverText(),
+ db.lastError().databaseText()), " Ooops ")
+
+
+ def buttonHelp_clicked(self):
+ TQMessageBox.information(self, "About Connecting",
+ "Here you specify userid, password, host and database\n"
+ "for the PyTQt sql examples. If you encounter any problems,\n"
+ "please read the README file in this folder before posting.\n\n"
+ "Thanks,\nHans-Peter Jansen <hpj@urpla.net>\n")
+
+
+if __name__ == "__main__":
+ app = TQApplication(sys.argv)
+ if createConnection():
+ print("ok")
+ else:
+ print("cancel")
diff --git a/examples/SQL/dbpar.py b/examples/SQL/dbpar.py
new file mode 100644
index 0000000..19e6d9b
--- /dev/null
+++ b/examples/SQL/dbpar.py
@@ -0,0 +1,22 @@
+# sql examples default database parameter
+
+# you can create a local_dbpar.py module with definitons
+# of your own parameters to overrule these defaults
+
+#DB_DRIVER = "TQPSQL7"
+DB_DRIVER = "TQMYSQL3"
+# list of servers
+DB_HOSTNAMES = ["localhost"]
+# list of databases
+DB_DATABASES = ["testdb"]
+# database user id
+DB_USERNAME = ""
+# database password
+DB_PASSWORD = ""
+
+# remove this in your local_dbpar.py
+try:
+ from local_dbpar import *
+except:
+ pass
+
diff --git a/examples/SQL/form1.ui b/examples/SQL/form1.ui
new file mode 100644
index 0000000..118a84e
--- /dev/null
+++ b/examples/SQL/form1.ui
@@ -0,0 +1,77 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>Form1</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>370</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Form1</string>
+ </property>
+ <widget class="TQDataTable">
+ <column>
+ <property name="text">
+ <string>Forename</string>
+ </property>
+ <property name="field">
+ <string>forename</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Surname</string>
+ </property>
+ <property name="field">
+ <string>surname</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Salary</string>
+ </property>
+ <property name="field">
+ <string>salary</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Statusid</string>
+ </property>
+ <property name="field">
+ <string>statusid</string>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>DataTable2</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>370</height>
+ </rect>
+ </property>
+ <property name="sorting">
+ <bool>true</bool>
+ </property>
+ <property name="confirmDelete">
+ <bool>true</bool>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ </stringlist>
+ </property>
+ </widget>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/form2.ui b/examples/SQL/form2.ui
new file mode 100644
index 0000000..4856e39
--- /dev/null
+++ b/examples/SQL/form2.ui
@@ -0,0 +1,327 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>Form2</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>Form2</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>367</width>
+ <height>152</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Form2</string>
+ </property>
+ <widget class="TQDataBrowser">
+ <property name="name">
+ <cstring>DataBrowser1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>366</width>
+ <height>150</height>
+ </rect>
+ </property>
+ <property name="sort">
+ <stringlist>
+ <string>surname ASC</string>
+ <string>forename ASC</string>
+ </stringlist>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ </stringlist>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>Layout2</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>labelSurname</cstring>
+ </property>
+ <property name="text">
+ <string>Surname</string>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="1" column="3">
+ <property name="name">
+ <cstring>TQSpinBoxStatusid</cstring>
+ </property>
+ <property name="maxValue">
+ <number>2147483647</number>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ <string>statusid</string>
+ </stringlist>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>TQLineEditSurname</cstring>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ <string>surname</string>
+ </stringlist>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="2">
+ <property name="name">
+ <cstring>labelStatusid</cstring>
+ </property>
+ <property name="text">
+ <string>Statusid</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>labelForename</cstring>
+ </property>
+ <property name="text">
+ <string>Forename</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="0" column="3">
+ <property name="name">
+ <cstring>TQLineEditSalary</cstring>
+ </property>
+ <property name="alignment">
+ <set>AlignRight</set>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ <string>salary</string>
+ </stringlist>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="2">
+ <property name="name">
+ <cstring>labelSalary</cstring>
+ </property>
+ <property name="text">
+ <string>Salary</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>TQLineEditForename</cstring>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ <string>forename</string>
+ </stringlist>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>Layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonFirst</cstring>
+ </property>
+ <property name="text">
+ <string>|&lt; &amp;First</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonPrev</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;&lt; &amp;Prev</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonNext</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Next &gt;&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonLast</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Last &gt;|</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonInsert</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Insert</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonUpdate</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Update</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonDelete</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+</widget>
+<connections>
+ <connection>
+ <sender>PushButtonFirst</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>first()</slot>
+ </connection>
+ <connection>
+ <sender>DataBrowser1</sender>
+ <signal>firstRecordAvailable( bool )</signal>
+ <receiver>PushButtonFirst</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonPrev</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>prev()</slot>
+ </connection>
+ <connection>
+ <sender>DataBrowser1</sender>
+ <signal>prevRecordAvailable( bool )</signal>
+ <receiver>PushButtonPrev</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonNext</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>next()</slot>
+ </connection>
+ <connection>
+ <sender>DataBrowser1</sender>
+ <signal>nextRecordAvailable( bool )</signal>
+ <receiver>PushButtonNext</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonLast</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>last()</slot>
+ </connection>
+ <connection>
+ <sender>DataBrowser1</sender>
+ <signal>lastRecordAvailable( bool )</signal>
+ <receiver>PushButtonLast</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonInsert</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>insert()</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonUpdate</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>update()</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonDelete</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>del()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>TQLineEditForename</tabstop>
+ <tabstop>TQLineEditSurname</tabstop>
+ <tabstop>TQLineEditSalary</tabstop>
+ <tabstop>TQSpinBoxStatusid</tabstop>
+ <tabstop>PushButtonFirst</tabstop>
+ <tabstop>PushButtonPrev</tabstop>
+ <tabstop>PushButtonNext</tabstop>
+ <tabstop>PushButtonLast</tabstop>
+ <tabstop>PushButtonInsert</tabstop>
+ <tabstop>PushButtonUpdate</tabstop>
+ <tabstop>PushButtonDelete</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/frmconnect.py b/examples/SQL/frmconnect.py
new file mode 100644
index 0000000..97fb406
--- /dev/null
+++ b/examples/SQL/frmconnect.py
@@ -0,0 +1,120 @@
+# Form implementation generated from reading ui file 'frmconnect.ui'
+#
+# Created: Sam Jul 6 12:47:10 2002
+# by: The PyTQt User Interface Compiler (pyuic)
+#
+# WARNING! All changes made in this file will be lost!
+
+
+from python_tqt.qt import *
+
+
+class frmConnect(TQDialog):
+ def __init__(self,parent = None,name = None,modal = 0,fl = 0):
+ TQDialog.__init__(self,parent,name,modal,fl)
+
+ if name == None:
+ self.setName("frmConnect")
+
+ self.resize(415,154)
+ self.setCaption(self.trUtf8("Connecting"))
+ self.setSizeGripEnabled(1)
+
+ frmConnectLayout = TQGridLayout(self,1,1,11,6,"frmConnectLayout")
+
+ Layout7 = TQVBoxLayout(None,0,6,"Layout7")
+
+ self.buttonOK = TQPushButton(self,"buttonOK")
+ self.buttonOK.setText(self.trUtf8("&OK"))
+ self.buttonOK.setAutoDefault(1)
+ self.buttonOK.setDefault(1)
+ TQToolTip.add(self.buttonOK,self.trUtf8("Connect to Database"))
+ Layout7.addWidget(self.buttonOK)
+
+ self.buttonCancel = TQPushButton(self,"buttonCancel")
+ self.buttonCancel.setText(self.trUtf8("&Cancel"))
+ TQToolTip.add(self.buttonCancel,self.trUtf8("Cancel Connecting"))
+ Layout7.addWidget(self.buttonCancel)
+
+ self.buttonHelp = TQPushButton(self,"buttonHelp")
+ self.buttonHelp.setText(self.trUtf8("&Help"))
+ TQToolTip.add(self.buttonHelp,self.trUtf8("About Connecting"))
+ Layout7.addWidget(self.buttonHelp)
+ spacer = TQSpacerItem(0,0,TQSizePolicy.Minimum,TQSizePolicy.Expanding)
+ Layout7.addItem(spacer)
+
+ frmConnectLayout.addLayout(Layout7,0,1)
+
+ self.grpConnection = TQGroupBox(self,"grpConnection")
+ self.grpConnection.setTitle(self.trUtf8(""))
+ self.grpConnection.setColumnLayout(0,TQt.Vertical)
+ self.grpConnection.layout().setSpacing(6)
+ self.grpConnection.layout().setMargin(11)
+ grpConnectionLayout = TQGridLayout(self.grpConnection.layout())
+ grpConnectionLayout.setAlignment(TQt.AlignTop)
+
+ self.txtName = TQLineEdit(self.grpConnection,"txtName")
+ self.txtName.setMaxLength(16)
+ TQToolTip.add(self.txtName,self.trUtf8("Database User ID"))
+
+ grpConnectionLayout.addWidget(self.txtName,0,1)
+
+ self.lblDatabase = TQLabel(self.grpConnection,"lblDatabase")
+ self.lblDatabase.setText(self.trUtf8("&Database"))
+
+ grpConnectionLayout.addWidget(self.lblDatabase,3,0)
+
+ self.lblServer = TQLabel(self.grpConnection,"lblServer")
+ self.lblServer.setText(self.trUtf8("&Server"))
+
+ grpConnectionLayout.addWidget(self.lblServer,2,0)
+
+ self.lblName = TQLabel(self.grpConnection,"lblName")
+ self.lblName.setText(self.trUtf8("&Name"))
+
+ grpConnectionLayout.addWidget(self.lblName,0,0)
+
+ self.cmbDatabase = TQComboBox(0,self.grpConnection,"cmbDatabase")
+ self.cmbDatabase.setEditable(1)
+ self.cmbDatabase.setAutoCompletion(1)
+ self.cmbDatabase.setDuplicatesEnabled(0)
+ TQToolTip.add(self.cmbDatabase,self.trUtf8("Database Name"))
+
+ grpConnectionLayout.addWidget(self.cmbDatabase,3,1)
+
+ self.txtPasswd = TQLineEdit(self.grpConnection,"txtPasswd")
+ self.txtPasswd.setMaxLength(16)
+ self.txtPasswd.setEchoMode(TQLineEdit.Password)
+ TQToolTip.add(self.txtPasswd,self.trUtf8("Database User Password"))
+
+ grpConnectionLayout.addWidget(self.txtPasswd,1,1)
+
+ self.lblPasswd = TQLabel(self.grpConnection,"lblPasswd")
+ self.lblPasswd.setText(self.trUtf8("&Password"))
+
+ grpConnectionLayout.addWidget(self.lblPasswd,1,0)
+
+ self.cmbServer = TQComboBox(0,self.grpConnection,"cmbServer")
+ self.cmbServer.setEditable(1)
+ self.cmbServer.setAutoCompletion(1)
+ self.cmbServer.setDuplicatesEnabled(0)
+ TQToolTip.add(self.cmbServer,self.trUtf8("Database Server Address"))
+
+ grpConnectionLayout.addWidget(self.cmbServer,2,1)
+
+ frmConnectLayout.addWidget(self.grpConnection,0,0)
+
+ self.connect(self.buttonOK,SIGNAL("clicked()"),self,SLOT("accept()"))
+ self.connect(self.buttonCancel,SIGNAL("clicked()"),self,SLOT("reject()"))
+
+ self.setTabOrder(self.txtName,self.txtPasswd)
+ self.setTabOrder(self.txtPasswd,self.cmbServer)
+ self.setTabOrder(self.cmbServer,self.cmbDatabase)
+ self.setTabOrder(self.cmbDatabase,self.buttonOK)
+ self.setTabOrder(self.buttonOK,self.buttonCancel)
+ self.setTabOrder(self.buttonCancel,self.buttonHelp)
+
+ self.lblDatabase.setBuddy(self.cmbDatabase)
+ self.lblServer.setBuddy(self.cmbServer)
+ self.lblName.setBuddy(self.txtName)
+ self.lblPasswd.setBuddy(self.txtPasswd)
diff --git a/examples/SQL/frmconnect.ui b/examples/SQL/frmconnect.ui
new file mode 100644
index 0000000..f2017ee
--- /dev/null
+++ b/examples/SQL/frmconnect.ui
@@ -0,0 +1,245 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>frmConnect</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>frmConnect</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>415</width>
+ <height>154</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Connecting</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="1">
+ <property name="name">
+ <cstring>Layout7</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonOK</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Connect to Database</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Cancel Connecting</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonHelp</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>About Connecting</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="TQGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>grpConnection</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>txtName</cstring>
+ </property>
+ <property name="maxLength">
+ <number>16</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Database User ID</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="3" column="0">
+ <property name="name">
+ <cstring>lblDatabase</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Database</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cmbDatabase</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>lblServer</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Server</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cmbServer</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>lblName</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Name</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>txtName</cstring>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="3" column="1">
+ <property name="name">
+ <cstring>cmbDatabase</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="autoCompletion">
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Database Name</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>txtPasswd</cstring>
+ </property>
+ <property name="maxLength">
+ <number>16</number>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Database User Password</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>lblPasswd</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Password</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>txtPasswd</cstring>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="2" column="1">
+ <property name="name">
+ <cstring>cmbServer</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="autoCompletion">
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Database Server Address</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonOK</sender>
+ <signal>clicked()</signal>
+ <receiver>frmConnect</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>frmConnect</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>txtName</tabstop>
+ <tabstop>txtPasswd</tabstop>
+ <tabstop>cmbServer</tabstop>
+ <tabstop>cmbDatabase</tabstop>
+ <tabstop>buttonOK</tabstop>
+ <tabstop>buttonCancel</tabstop>
+ <tabstop>buttonHelp</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/runform1.py b/examples/SQL/runform1.py
new file mode 100755
index 0000000..2e01b7e
--- /dev/null
+++ b/examples/SQL/runform1.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+
+from form1 import Form1
+from dbconnect import createConnection
+
+class mainWindow(Form1):
+ def __init__(self,parent = None,name = None,fl = 0):
+ Form1.__init__(self,parent,name,fl)
+
+if __name__ == "__main__":
+ a = TQApplication(sys.argv)
+ if createConnection():
+ TQObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
+ w = mainWindow()
+ a.setMainWidget(w)
+ w.show()
+ a.exec_loop()
+
diff --git a/examples/SQL/runform2.py b/examples/SQL/runform2.py
new file mode 100755
index 0000000..0184e9d
--- /dev/null
+++ b/examples/SQL/runform2.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+
+from form2 import Form2
+from dbconnect import createConnection
+
+class mainWindow(Form2):
+ def __init__(self,parent = None,name = None,fl = 0):
+ Form2.__init__(self,parent,name,fl)
+
+if __name__ == "__main__":
+ a = TQApplication(sys.argv)
+ if createConnection():
+ TQObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
+ w = mainWindow()
+ a.setMainWidget(w)
+ w.show()
+ a.exec_loop()
+
diff --git a/examples/SQL/runsqlex.py b/examples/SQL/runsqlex.py
new file mode 100755
index 0000000..2235699
--- /dev/null
+++ b/examples/SQL/runsqlex.py
@@ -0,0 +1,151 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from sqlex import SqlEx
+from connect import ConnectDialog
+
+from dbpar import *
+
+TRUE = 1
+FALSE = 0
+
+def showError(err, parent):
+ errStr = TQString("The database reported an error:\n\n")
+ if not err.databaseText().isEmpty():
+ errStr.append(err.databaseText())
+ errStr.append("\n")
+ if not err.driverText().isEmpty():
+ errStr.append(err.driverText())
+ errStr.append("\n")
+ TQMessageBox.warning(parent, "Error", errStr)
+
+class CustomSqlCursor(TQSqlCursor):
+ def __init__(self, query = None, autopopulate = TRUE, db = None):
+ TQSqlCursor.__init__(self, None, autopopulate, db)
+ self.execQuery(query)
+ if self.isSelect() and autopopulate:
+ fields = self.driver().recordInfo(self)
+ for f in fields:
+ self.append(f)
+ self.setMode(TQSqlCursor.ReadOnly)
+
+ def select(self, filter, sort = TQSqlIndex()):
+ return self.execQuery(self.lastQuery())
+
+ def primaryIndex(self, prime = TRUE):
+ return TQSqlIndex()
+
+ def insert(self, invalidate = TRUE):
+ return FALSE
+
+ def update(self, invalidate = TRUE):
+ return FALSE
+
+ def delRecords(self, invalidate = TRUE):
+ return FALSE
+
+ def setName(self, name, autopopulate = TRUE):
+ return
+
+
+class MainWindow(SqlEx):
+ def __init__(self,parent = None,name = None,fl = 0):
+ SqlEx.__init__(self,parent,name,fl)
+ self.conDiag = ConnectDialog(self, "Connection Dialog", TRUE)
+ self.firstconn = TRUE
+
+ def dbConnect(self):
+ if self.firstconn:
+ self.firstconn = FALSE
+ self.conDiag.editUsername.setText(DB_USERNAME)
+ self.conDiag.editPassword.setText(DB_PASSWORD)
+ self.conDiag.editHostname.setText(DB_HOSTNAMES[0])
+ self.conDiag.editDatabase.setText(DB_DATABASES[0])
+ for i in range(self.conDiag.comboDriver.count()):
+ if str(self.conDiag.comboDriver.text(i)) == DB_DRIVER:
+ self.conDiag.comboDriver.setCurrentItem(i)
+ break
+ if self.conDiag.exec_loop() != TQDialog.Accepted:
+ return
+ if self.dt.sqlCursor():
+ self.dt.setSqlCursor()
+
+ # close old connection (if any)
+ if TQSqlDatabase.contains("SqlEx"):
+ oldDb = TQSqlDatabase.database("SqlEx")
+ oldDb.close()
+ TQSqlDatabase.removeDatabase("SqlEx")
+
+ # open the new connection
+ db = TQSqlDatabase.addDatabase(self.conDiag.comboDriver.currentText(), "SqlEx")
+ if not db:
+ TQMessageBox.warning(self, "Error", "Could not open database")
+ return
+
+ db.setHostName(self.conDiag.editHostname.text())
+ db.setDatabaseName(self.conDiag.editDatabase.text())
+ db.setPort(self.conDiag.portSpinBox.value())
+ if not db.open(self.conDiag.editUsername.text(),
+ self.conDiag.editPassword.text()):
+ showError(db.lastError(), self)
+ return
+
+ self.lbl.setText("Double-Click on a table-name to view the contents")
+ self.lv.clear()
+
+ tables = db.tables()
+ for t in tables:
+ lvi = TQListViewItem(self.lv, t)
+ fields = db.recordInfo(t)
+ for f in fields:
+ req = "?"
+ if f.isRequired() > 0:
+ req = "Yes"
+ elif f.isRequired() == 0:
+ req = "No"
+ fi = TQListViewItem(lvi, f.name(), TQVariant.typeToName(f.type()), req)
+ lvi.insertItem(fi)
+ self.lv.insertItem(lvi)
+
+ self.submitBtn.setEnabled(TRUE)
+
+ def execQuery(self):
+ cursor = CustomSqlCursor(self.te.text(), TRUE,
+ TQSqlDatabase.database("SqlEx", TRUE))
+ if cursor.isSelect():
+ self.dt.setSqlCursor(cursor, TRUE, TRUE)
+ self.dt.refresh()
+ txt = TQString("Query OK")
+ if cursor.size() >= 0:
+ txt.append(", returned rows: %s" % cursor.size())
+ self.lbl.setText(txt)
+ else:
+ if not cursor.isActive():
+ # an error occured
+ showError(cursor.lastError(), self)
+ else:
+ self.lbl.setText("Query OK, affected rows: %s" %
+ cursor.numRowsAffected())
+
+ def showTable(self, item):
+ i = item.parent()
+ if not i:
+ i = item
+ cursor = TQSqlCursor(i.text(0), TRUE, TQSqlDatabase.database("SqlEx", TRUE))
+ self.dt.setSqlCursor(cursor, TRUE, TRUE)
+ self.dt.setSort(cursor.primaryIndex())
+ self.dt.refresh(TQDataTable.RefreshAll)
+ self.lbl.setText("Displaying table %s" % i.text(0))
+
+
+if __name__ == "__main__":
+ a = TQApplication(sys.argv)
+ TQObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
+ w = MainWindow()
+ a.setMainWidget(w)
+ w.show()
+ a.exec_loop()
+
diff --git a/examples/SQL/sqlcustom1.py b/examples/SQL/sqlcustom1.py
new file mode 100755
index 0000000..4da8f8a
--- /dev/null
+++ b/examples/SQL/sqlcustom1.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: sqlcustom1.py,v 1.3 2002/07/06 13:35:41 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from dbconnect import createConnection
+
+TRUE = 1
+FALSE = 0
+
+class CustomEdit(TQLineEdit):
+ def __init__(self, parent = None, name = None):
+ TQLineEdit.__init__(self, parent, name)
+ TQObject.connect(self, SIGNAL("textChanged(const TQString &)"),
+ self.changed)
+
+ def changed(self, line):
+ self.setUpperLine(line)
+
+ def setUpperLine(self, line):
+ self.upperLineText = line.upper()
+ self.setText(self.upperLineText)
+
+
+class FormDialog(TQDialog):
+ def __init__(self):
+ TQDialog.__init__(self)
+ forenameLabel = TQLabel("Forename:", self)
+ forenameEdit = CustomEdit(self)
+ surnameLabel = TQLabel("Surname:", self)
+ surnameEdit = CustomEdit(self)
+ salaryLabel = TQLabel("Salary:", self)
+ salaryEdit = TQLineEdit(self)
+ salaryEdit.setAlignment(TQt.AlignRight)
+ saveButton = TQPushButton("&Save", self)
+ self.connect(saveButton, SIGNAL("clicked()"), self.save)
+
+ grid = TQGridLayout(self)
+ grid.addWidget(forenameLabel, 0, 0)
+ grid.addWidget(forenameEdit, 0, 1)
+ grid.addWidget(surnameLabel, 1, 0)
+ grid.addWidget(surnameEdit, 1, 1)
+ grid.addWidget(salaryLabel, 2, 0)
+ grid.addWidget(salaryEdit, 2, 1)
+ grid.addWidget(saveButton, 3, 0)
+ grid.activate()
+
+ self.staffCursor = TQSqlCursor("staff")
+ self.staffCursor.setTrimmed("forename", TRUE)
+ self.staffCursor.setTrimmed("surname", TRUE)
+ self.idIndex = self.staffCursor.index("id")
+ self.staffCursor.select(self.idIndex)
+ self.staffCursor.first()
+
+ self.propMap = TQSqlPropertyMap()
+ self.propMap.insert(forenameEdit.className(), "upperLine")
+
+ self.sqlForm = TQSqlForm()
+ self.sqlForm.setRecord(self.staffCursor.primeUpdate())
+ self.sqlForm.installPropertyMap(self.propMap)
+ self.sqlForm.insert(forenameEdit, "forename")
+ self.sqlForm.insert(surnameEdit, "surname")
+ self.sqlForm.insert(salaryEdit, "salary")
+ self.sqlForm.readFields()
+
+ def save(self):
+ self.sqlForm.writeFields()
+ self.staffCursor.update()
+ self.staffCursor.select(self.idIndex)
+ self.staffCursor.first()
+
+
+if __name__=='__main__':
+ app = TQApplication( sys.argv )
+
+ if createConnection():
+ formDialog = FormDialog()
+ formDialog.show()
+
+ app.setMainWidget(formDialog)
+ app.exec_loop()
+
+
diff --git a/examples/SQL/sqlex.ui b/examples/SQL/sqlex.ui
new file mode 100644
index 0000000..64b3d0f
--- /dev/null
+++ b/examples/SQL/sqlex.ui
@@ -0,0 +1,303 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>SqlEx</class>
+<widget class="TQWidget">
+ <property name="name">
+ <cstring>SqlEx</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>669</width>
+ <height>438</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>SQL Browser</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>Layout23</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lbl</cstring>
+ </property>
+ <property name="text">
+ <string>Press "Connect" to open a database</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>conBtn</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>&amp;Connect...</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQSplitter" row="0" column="0">
+ <property name="name">
+ <cstring>vsplit</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <widget class="TQSplitter">
+ <property name="name">
+ <cstring>hsplit</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <widget class="TQListView">
+ <column>
+ <property name="text">
+ <string>Tables</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Type</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Required</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lv</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ <widget class="TQDataTable">
+ <property name="name">
+ <cstring>dt</cstring>
+ </property>
+ <property name="frameworkCode" stdset="0">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </widget>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>gb</cstring>
+ </property>
+ <property name="title">
+ <string>SQL Query</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>Layout22</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQTextEdit">
+ <property name="name">
+ <cstring>te</cstring>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout21</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>submitBtn</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>&amp;Submit</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>clearBtn</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>C&amp;lear</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>clearBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>te</receiver>
+ <slot>clear()</slot>
+ </connection>
+ <connection>
+ <sender>conBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>SqlEx</receiver>
+ <slot>dbConnect()</slot>
+ </connection>
+ <connection>
+ <sender>lv</sender>
+ <signal>returnPressed(TQListViewItem*)</signal>
+ <receiver>SqlEx</receiver>
+ <slot>showTable(TQListViewItem*)</slot>
+ </connection>
+ <connection>
+ <sender>lv</sender>
+ <signal>doubleClicked(TQListViewItem*)</signal>
+ <receiver>SqlEx</receiver>
+ <slot>showTable(TQListViewItem*)</slot>
+ </connection>
+ <connection>
+ <sender>submitBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>SqlEx</receiver>
+ <slot>execQuery()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">sqlex.ui.h</include>
+</includes>
+<slots>
+ <slot>init()</slot>
+ <slot>dbConnect()</slot>
+ <slot>showTable( TQListViewItem * )</slot>
+ <slot>execQuery()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/sqlex.ui.h b/examples/SQL/sqlex.ui.h
new file mode 100644
index 0000000..07edcd0
--- /dev/null
+++ b/examples/SQL/sqlex.ui.h
@@ -0,0 +1,35 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename slots use TQt Designer which will
+** update this file, preserving your code. Create an init() slot in place of
+** a constructor, and a destroy() slot in place of a destructor.
+*****************************************************************************/
+
+
+void SqlEx::init()
+{
+self.hsplit.setSizes([250])
+self.hsplit.setResizeMode(self.lv, TQSplitter.KeepSize)
+self.vsplit.setResizeMode(self.gb, TQSplitter.KeepSize)
+self.submitBtn.setEnabled(0)
+}
+
+
+void SqlEx::dbConnect()
+{
+
+}
+
+
+void SqlEx::showTable( TQListViewItem * )
+{
+
+}
+
+
+
+void SqlEx::execQuery()
+{
+
+}
diff --git a/examples/SQL/sqlsubclass5.py b/examples/SQL/sqlsubclass5.py
new file mode 100755
index 0000000..0fdc78c
--- /dev/null
+++ b/examples/SQL/sqlsubclass5.py
@@ -0,0 +1,151 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: sqlsubclass5.py,v 1.3 2002/07/06 13:35:41 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from dbconnect import createConnection
+
+TRUE = 1
+FALSE = 0
+
+class CustomTable(TQDataTable):
+ def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None):
+ TQDataTable.__init__(self, cursor, autoPopulate, parent, name)
+
+ def paintField(self, p, field, cr, b):
+ if not field:
+ return
+ fn = str(field.name())
+ if fn == "pricesid":
+ query = TQSqlQuery("SELECT name FROM prices WHERE id=%s" %
+ field.value().toString())
+ value = ""
+ if next(query):
+ value = query.value(0).toString()
+ p.drawText(2, 2, cr.width()-4, cr.height()-4,
+ self.fieldAlignment(field), value)
+ elif fn == "quantity":
+ p.drawText(2, 2, cr.width()-6, cr.height()-4,
+ TQt.AlignRight|TQt.AlignVCenter, field.value().toString())
+ elif fn in ("price", "cost"):
+ v = field.value().toDouble()
+ if v < 0:
+ p.setPen(TQColor("red"))
+ value = TQString("%.2f \u20ac" % v)
+ p.drawText(2, 2, cr.width()-6, cr.height()-4,
+ TQt.AlignRight|TQt.AlignVCenter, value)
+ elif fn == "paiddate":
+ if field.value().toDate().isNull():
+ v = TQString("not yet")
+ p.setPen(TQColor("red"))
+ else:
+ v = field.value().toDate().toString(TQt.LocalDate)
+ p.drawText(2, 2, cr.width()-4, cr.height()-4,
+ TQt.AlignHCenter|TQt.AlignVCenter, v)
+ else:
+ TQDataTable.paintField(self, p, field, cr, b)
+
+
+class InvoiceItemCursor(TQSqlCursor):
+ def __init__(self):
+ TQSqlCursor.__init__(self, "invoiceitem")
+
+ productPrice = TQSqlFieldInfo("price", TQVariant.Double)
+ self.append(productPrice)
+ self.setCalculated(productPrice.name(), TRUE)
+
+ productCost = TQSqlFieldInfo("cost", TQVariant.Double)
+ self.append(productCost)
+ self.setCalculated(productCost.name(), TRUE)
+
+ def calculateField(self, name):
+ fn = str(name)
+ if fn == "productname":
+ query = TQSqlQuery("SELECT name FROM prices WHERE id=%d;" %
+ (self.field("pricesid").value().toInt()))
+ if next(query):
+ return query.value(0)
+ elif fn == "price":
+ query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" %
+ (self.field("pricesid").value().toInt()))
+ if next(query):
+ return query.value(0)
+ elif fn == "cost":
+ query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" %
+ (self.field("pricesid").value().toInt()))
+ if next(query):
+ return TQVariant(query.value(0).toDouble() *
+ self.value("quantity").toDouble())
+ return TQVariant(TQString.null)
+
+ def primeInsert(self):
+ buffer = self.editBuffer()
+ buffer.setValue("id", TQVariant(0))
+ buffer.setValue("paiddate", TQVariant(TQDate.currentDate()))
+ buffer.setValue("quantity", TQVariant(1))
+ return buffer
+
+
+class ProductPicker(TQComboBox):
+ def __init__(self, parent = None, name = None):
+ TQComboBox.__init__(self, parent, name)
+ cur = TQSqlCursor("prices")
+ cur.select(cur.index("id"))
+ while next(cur):
+ self.insertItem(cur.value("name").toString(), cur.value("id").toInt())
+
+
+class CustomSqlEditorFactory(TQSqlEditorFactory):
+ def __init__(self):
+ TQSqlEditorFactory.__init__(self)
+
+ def createEditor(self, parent, field):
+ try:
+ if str(field.name()) == "pricesid":
+ return ProductPicker(parent)
+ except AttributeError:
+ pass
+ return TQSqlEditorFactory.createEditor(self, parent, field)
+
+class Table(CustomTable):
+ def __init__(self):
+ self.invoiceItemCursor = InvoiceItemCursor()
+ TQDataTable.__init__(self, self.invoiceItemCursor)
+ self.propMap = TQSqlPropertyMap()
+ self.editorFactory = CustomSqlEditorFactory()
+ self.propMap.insert("ProductPicker", "pricesid")
+ self.installPropertyMap(self.propMap)
+ self.installEditorFactory(self.editorFactory)
+
+ for cn, ch in (("pricesid", "Product"),
+ ("quantity", "Quantity"),
+ ("price", "Price" ),
+ ("cost", "Cost"),
+ ("paiddate", "Paid")):
+ self.addColumn(cn, ch)
+ self.setColumnWidth(0 , 150)
+ self.setColumnWidth(1, 70)
+ self.resize(600, 250)
+ self.refresh()
+
+
+if __name__=='__main__':
+ app = TQApplication(sys.argv)
+ if createConnection():
+ t = Table()
+ app.setMainWidget(t)
+ t.show()
+ app.exec_loop()
+
+
diff --git a/examples/SQL/sqltable4.py b/examples/SQL/sqltable4.py
new file mode 100755
index 0000000..a8484c5
--- /dev/null
+++ b/examples/SQL/sqltable4.py
@@ -0,0 +1,118 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: sqltable4.py,v 1.3 2002/07/06 13:35:41 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from dbconnect import createConnection
+
+TRUE = 1
+FALSE = 0
+
+class CustomTable(TQDataTable):
+ def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None):
+ TQDataTable.__init__(self, cursor, autoPopulate, parent, name)
+
+ def paintField(self, p, field, cr, b):
+ if not field:
+ return
+ fn = str(field.name())
+ if fn in ("salary", "monsalary"):
+ v = field.value().toDouble()
+ if v < 0:
+ p.setPen(TQColor("red"))
+ value = TQString("%.2f \u20ac" % v)
+ #print unicode(value).encode("iso-8859-15")
+ p.drawText(2, 2, cr.width()-6, cr.height()-4,
+ TQt.AlignRight|TQt.AlignVCenter, value)
+ elif fn == "statusid":
+ query = TQSqlQuery("SELECT name FROM status WHERE id=%s" %
+ field.value().toString())
+ value = ""
+ if next(query):
+ value = query.value(0).toString()
+ p.drawText(2, 2, cr.width()-4, cr.height()-4,
+ self.fieldAlignment(field), value)
+ else:
+ TQDataTable.paintField(self, p, field, cr, b)
+
+
+class StatusPicker(TQComboBox):
+ def __init__(self, parent = None, name = None):
+ TQComboBox.__init__(self, parent, name)
+ cur = TQSqlCursor("status")
+ cur.select(cur.index("id"))
+ while next(cur):
+ self.insertItem(cur.value("name").toString(), cur.value("id").toInt())
+
+
+class CustomSqlEditorFactory(TQSqlEditorFactory):
+ def __init__(self):
+ TQSqlEditorFactory.__init__(self)
+
+ def createEditor(self, parent, field):
+ try:
+ if str(field.name()) == "statusid":
+ return StatusPicker(parent)
+ except AttributeError:
+ pass
+ return TQSqlEditorFactory.createEditor(self, parent, field)
+
+
+class StaffCursor(TQSqlCursor):
+ def __init__(self):
+ TQSqlCursor.__init__(self, "staff")
+ monSalary = TQSqlFieldInfo("monsalary", TQVariant.Double)
+ self.append(monSalary)
+ self.setCalculated(monSalary.name(), TRUE)
+
+ def calculateField(self, name):
+ if str(name) == "monsalary":
+ return TQVariant(self.value("salary").toDouble() / 12)
+ return TQVariant(TQString.null)
+
+
+class Table(CustomTable):
+ def __init__(self):
+ #self.staffCursor = TQSqlCursor("staff")
+ self.staffCursor = StaffCursor()
+ TQDataTable.__init__(self, self.staffCursor)
+ self.propMap = TQSqlPropertyMap()
+ self.editorFactory = CustomSqlEditorFactory()
+ self.propMap.insert("StatusPicker", "statusid")
+ self.installPropertyMap(self.propMap)
+ self.installEditorFactory(self.editorFactory)
+ for cn, ch in (("forename", "Forename"),
+ ("surname", "Surname" ),
+ ("salary", "Annual Salary"),
+ ("monsalary","Monthly Salary"),
+ ("statusid", "Status")):
+ self.addColumn(cn, ch)
+ self.order = TQStringList("surname")
+ self.order.append("forename")
+ self.setSort(self.order)
+ self.refresh()
+
+
+if __name__=='__main__':
+ app = TQApplication(sys.argv)
+ #app.setFont(TQFont("Verdana", 11))
+
+ if createConnection():
+ t = Table()
+ app.setMainWidget(t)
+ t.resize(600, 250)
+ t.show()
+ app.exec_loop()
+
+
diff --git a/examples/SQL/testdb_mysql.sql b/examples/SQL/testdb_mysql.sql
new file mode 100644
index 0000000..144d4c9
--- /dev/null
+++ b/examples/SQL/testdb_mysql.sql
@@ -0,0 +1,57 @@
+drop database testdb;
+create database testdb;
+use testdb;
+
+create table people (id integer primary key auto_increment,
+ name char(40));
+
+create table staff (id integer primary key auto_increment,
+ forename char(40),
+ surname char(40),
+ salary float(10,2),
+ statusid integer);
+
+create table status (id integer primary key,
+ name char(30));
+
+create table creditors (id integer primary key auto_increment,
+ forename char(40),
+ surname char(40),
+ city char(30));
+
+create table prices (id integer primary key,
+ name char(40),
+ price float);
+
+create table invoiceitem (id integer primary key auto_increment,
+ pricesid integer,
+ quantity integer,
+ paiddate date);
+
+insert into staff (forename, surname, salary, statusid) values
+ ("Hugo", "Hurtig", 123450.50, 0),
+ ("Alfred E.", "Neumann", 56780.90, 1),
+ ("Agate", "Schnell-Fertig", 12340.56, 2),
+ ("Emil", "Dotterschreck", -5670.23, 3),
+ ("Eugen", "Nutzlos", -7833.56, 3),
+ ("Harald", "Schmidt", -150000.0, 3),
+ ("Urmel", "auf dem Eis", 7778.0, 2);
+
+insert into status (id, name) values
+ (0, 'Chief'),
+ (1, 'Programmer'),
+ (2, 'Secretary'),
+ (3, 'Driver');
+
+insert into prices (id, name, price) values
+ (0, "Waschbecken", 150.25),
+ (1, "Wellensittich", 27.95),
+ (2, "Roter Papagei", 850.0),
+ (3, "Spam & Eggs", -7.50),
+ (4, "Renault Espace", 9000.0),
+ (5, "Tux, der Pinguin", 65.35),
+ (6, "Makroskop", 985000.0),
+ (7, "Regenbaum", 1235.65),
+ (8, "Bluterguß", 23.95),
+ (9, "Weltmeisterschaft", 2.95),
+ (10, "Premiere Dekoder", -185.75);
diff --git a/examples/SQL/testdb_pg.sql b/examples/SQL/testdb_pg.sql
new file mode 100644
index 0000000..73a4270
--- /dev/null
+++ b/examples/SQL/testdb_pg.sql
@@ -0,0 +1,232 @@
+--
+-- Selected TOC Entries:
+--
+--
+-- TOC Entry ID 1 (OID 0)
+--
+-- Name: testdb Type: DATABASE Owner: postgres
+--
+
+CREATE DATABASE "testdb";
+
+\connect testdb postgres
+--
+-- TOC Entry ID 16 (OID 17332)
+--
+-- Name: people Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "people" (
+ "id" integer DEFAULT nextval('people_id_seq'::text) NOT NULL,
+ "name" character(40),
+ Constraint "people_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 17 (OID 17335)
+--
+-- Name: staff Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "staff" (
+ "id" integer DEFAULT nextval('staff_id_seq'::text) NOT NULL,
+ "forename" character(40),
+ "surname" character(40),
+ "salary" money,
+ "statusid" integer,
+ Constraint "staff_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 18 (OID 17338)
+--
+-- Name: status Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "status" (
+ "id" integer NOT NULL,
+ "name" character(30),
+ Constraint "status_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 19 (OID 17341)
+--
+-- Name: creditors Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "creditors" (
+ "id" integer DEFAULT nextval('creditors_id_seq'::text) NOT NULL,
+ "forename" character(40),
+ "surname" character(40),
+ "city" character(30),
+ Constraint "creditors_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 20 (OID 17344)
+--
+-- Name: prices Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "prices" (
+ "id" integer NOT NULL,
+ "name" character(40),
+ "price" real,
+ Constraint "prices_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 21 (OID 17347)
+--
+-- Name: invoiceitem Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "invoiceitem" (
+ "id" integer DEFAULT nextval('invoice_id_seq'::text) NOT NULL,
+ "pricesid" integer,
+ "quantity" integer,
+ "paiddate" date,
+ Constraint "invoiceitem_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 2 (OID 17351)
+--
+-- Name: people_id_seq Type: SEQUENCE Owner: postgres
+--
+
+CREATE SEQUENCE "people_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
+
+--
+-- TOC Entry ID 4 (OID 17353)
+--
+-- Name: staff_id_seq Type: SEQUENCE Owner: postgres
+--
+
+CREATE SEQUENCE "staff_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
+
+--
+-- TOC Entry ID 6 (OID 17355)
+--
+-- Name: creditors_id_seq Type: SEQUENCE Owner: postgres
+--
+
+CREATE SEQUENCE "creditors_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
+
+--
+-- TOC Entry ID 8 (OID 17357)
+--
+-- Name: invoice_id_seq Type: SEQUENCE Owner: postgres
+--
+
+CREATE SEQUENCE "invoice_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
+
+--
+-- Data for TOC Entry ID 28 (OID 17332)
+--
+-- Name: people Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "people" FROM stdin;
+\.
+--
+-- Data for TOC Entry ID 29 (OID 17335)
+--
+-- Name: staff Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "staff" FROM stdin;
+1 Hugo Hurtig $123,450.50 0
+2 Alfred E. Neumann $56,780.90 1
+3 Agate Schnell-Fertig $12,340.56 2
+6 Eugen Nutzlos -$7,833.56 3
+7 Harald Schmidt -$150,000.00 3
+4 Urmel auf dem Eis $7,778.00 2
+5 Emil Dotterschreck -$5,670.23 3
+\.
+--
+-- Data for TOC Entry ID 30 (OID 17338)
+--
+-- Name: status Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "status" FROM stdin;
+0 Chief
+1 Programmer
+2 Secretary
+3 Driver
+\.
+--
+-- Data for TOC Entry ID 31 (OID 17341)
+--
+-- Name: creditors Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "creditors" FROM stdin;
+\.
+--
+-- Data for TOC Entry ID 32 (OID 17344)
+--
+-- Name: prices Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "prices" FROM stdin;
+0 Waschbecken 150.25
+1 Wellensittich 27.95
+2 Roter Papagei 850
+3 Spam & Eggs -7.5
+4 Renault Espace 9000
+5 Tux, der Pinguin 65.35
+6 Makroskop 985000
+7 Regenbaum 1235.65
+8 Bluterguß 23.95
+9 Weltmeisterschaft 2.95
+10 Premiere Dekoder -185.75
+\.
+--
+-- Data for TOC Entry ID 33 (OID 17347)
+--
+-- Name: invoiceitem Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "invoiceitem" FROM stdin;
+\.
+--
+-- TOC Entry ID 3 (OID 17351)
+--
+-- Name: people_id_seq Type: SEQUENCE SET Owner: postgres
+--
+
+SELECT setval ('"people_id_seq"', 1, false);
+
+--
+-- TOC Entry ID 5 (OID 17353)
+--
+-- Name: staff_id_seq Type: SEQUENCE SET Owner: postgres
+--
+
+SELECT setval ('"staff_id_seq"', 8, true);
+
+--
+-- TOC Entry ID 7 (OID 17355)
+--
+-- Name: creditors_id_seq Type: SEQUENCE SET Owner: postgres
+--
+
+SELECT setval ('"creditors_id_seq"', 1, false);
+
+--
+-- TOC Entry ID 9 (OID 17357)
+--
+-- Name: invoice_id_seq Type: SEQUENCE SET Owner: postgres
+--
+
+SELECT setval ('"invoice_id_seq"', 1, false);
+
diff --git a/examples/aclock.py b/examples/aclock.py
new file mode 100755
index 0000000..66283ef
--- /dev/null
+++ b/examples/aclock.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+
+def TQMIN(x, y):
+ if y > x: return y
+ return x
+class AnalogClock(TQWidget):
+ def __init__(self, *args):
+ TQWidget.__init__(*(self,) + args)
+ self.time = TQTime.currentTime()
+ internalTimer = TQTimer(self)
+ self.connect(internalTimer, SIGNAL("timeout()"), self.timeout)
+ internalTimer.start(5000)
+
+ def timeout(self):
+ new_time = TQTime.currentTime()
+ if new_time.minute() != self.time.minute():
+ self.update()
+
+ def paintEvent(self, qe):
+ if not self.isVisible():
+ return
+ self.time = TQTime.currentTime()
+
+ pts = TQPointArray()
+ paint = TQPainter(self)
+ paint.setBrush(self.foregroundColor())
+
+ cp = TQPoint(self.rect().center())
+ d = TQMIN(self.width(), self.height())
+ matrix = TQWMatrix()
+ matrix.translate(cp.x(), cp.y())
+ matrix.scale(d/1000.0, d/1000.0)
+
+ h_angle = 30*(self.time.hour()%12 - 3) + self.time.minute()/2
+ matrix.rotate(h_angle)
+ paint.setWorldMatrix(matrix)
+ pts.setPoints([-20,0,0,-20,300,0,0,20])
+ paint.drawPolygon(pts)
+ matrix.rotate(-h_angle)
+
+ m_angle = (self.time.minute()-15)*6
+ matrix.rotate(m_angle)
+ paint.setWorldMatrix(matrix)
+ pts.setPoints([-10,0,0,-10,400,0,0,10])
+ paint.drawPolygon(pts)
+ matrix.rotate(-m_angle)
+
+ for i in range(0,12):
+ paint.setWorldMatrix(matrix)
+ paint.drawLine(450,0, 500,0)
+ matrix.rotate(30)
+
+a = TQApplication(sys.argv)
+clock = AnalogClock()
+clock.resize(100,100)
+a.setMainWidget(clock)
+clock.show()
+a.exec_loop()
diff --git a/examples/addressbook.py b/examples/addressbook.py
new file mode 100755
index 0000000..14b5679
--- /dev/null
+++ b/examples/addressbook.py
@@ -0,0 +1,457 @@
+#!/usr/bin/env python
+
+# A port to PyTQt of the application example from TQt v2.x.
+
+
+import sys, string
+from python_tqt.qt import *
+
+TRUE = 1
+FALSE = 0
+fileopen = [
+' 16 13 5 1',
+'. c #040404',
+'# c #808304',
+'a c None',
+'b c #f3f704',
+'c c #f3f7f3',
+'aaaaaaaaa...aaaa',
+'aaaaaaaa.aaa.a.a',
+'aaaaaaaaaaaaa..a',
+'a...aaaaaaaa...a',
+'.bcb.......aaaaa',
+'.cbcbcbcbc.aaaaa',
+'.bcbcbcbcb.aaaaa',
+'.cbcb...........',
+'.bcb.#########.a',
+'.cb.#########.aa',
+'.b.#########.aaa',
+'..#########.aaaa',
+'...........aaaaa'
+]
+
+filesave = [
+' 14 14 4 1',
+'. c #040404',
+'# c #808304',
+'a c #bfc2bf',
+'b c None',
+'..............',
+'.#.aaaaaaaa.a.',
+'.#.aaaaaaaa...',
+'.#.aaaaaaaa.#.',
+'.#.aaaaaaaa.#.',
+'.#.aaaaaaaa.#.',
+'.#.aaaaaaaa.#.',
+'.##........##.',
+'.############.',
+'.##.........#.',
+'.##......aa.#.',
+'.##......aa.#.',
+'.##......aa.#.',
+'b.............'
+]
+
+fileprint = [
+' 16 14 6 1',
+'. c #000000',
+'# c #848284',
+'a c #c6c3c6',
+'b c #ffff00',
+'c c #ffffff',
+'d c None',
+'ddddd.........dd',
+'dddd.cccccccc.dd',
+'dddd.c.....c.ddd',
+'ddd.cccccccc.ddd',
+'ddd.c.....c....d',
+'dd.cccccccc.a.a.',
+'d..........a.a..',
+'.aaaaaaaaaa.a.a.',
+'.............aa.',
+'.aaaaaa###aa.a.d',
+'.aaaaaabbbaa...d',
+'.............a.d',
+'d.aaaaaaaaa.a.dd',
+'dd...........ddd'
+]
+
+class ABCentralWidget( TQWidget ):
+ def __init__( self, *args ):
+ TQWidget.__init__(*(self, ) + args)
+ self.mainGrid = TQGridLayout( self, 2, 1, 5, 5 )
+
+ self.setupTabWidget()
+ self.setupListView()
+
+ self.mainGrid.setRowStretch( 0, 0 )
+ self.mainGrid.setRowStretch( 1, 1 )
+
+ def save( self, filename ):
+ if not self.listView.firstChild():
+ return
+
+ f = TQFile( filename )
+ if not f.open( IO_WriteOnly ):
+ return
+
+ t = TQTextStream( f )
+
+ #it = TQListViewItemIterator( self.listView )
+
+ while not t.eof():
+ item = TQListViewItem( self.listView )
+ for i in range (0, 4):
+ t << item.text( i ) << '\n'
+ #for it in it.current():
+ #for i in range (0, 4):
+ #t << it.current().text[ i ] << "\n"
+
+ f.close()
+
+
+ def load( self, filename ):
+ self.listView.clear()
+
+ f = TQFile( filename )
+ if not f.open( IO_ReadOnly ):
+ return
+
+ t = TQTextStream( f )
+
+ while not t.eof():
+ item = TQListViewItem( self.listView )
+ for i in range (0, 4):
+ item.setText( i, t.readLine() )
+
+ f.close();
+
+
+ def setupTabWidget( self ):
+ self.tabWidget = TQTabWidget( self )
+
+ self.input = TQWidget( self.tabWidget )
+ self.grid1 = TQGridLayout( self.input, 2, 5, 5, 5 )
+
+ self.liFirstName = TQLabel( 'First &Name', self.input )
+ self.liFirstName.resize( self.liFirstName.sizeHint() )
+ self.grid1.addWidget( self.liFirstName, 0, 0 )
+
+ self.liLastName = TQLabel( '&Last Name', self.input )
+ self.liLastName.resize( self.liLastName.sizeHint() )
+ self.grid1.addWidget( self.liLastName, 0, 1 )
+
+ self.liAddress = TQLabel( '&Address', self.input )
+ self.liAddress.resize( self.liAddress.sizeHint() )
+ self.grid1.addWidget( self.liAddress, 0, 2 )
+
+ self.liEMail = TQLabel( '&E-Mail', self.input )
+ self.liEMail.resize( self.liEMail.sizeHint() )
+ self.grid1.addWidget( self.liEMail, 0, 3 )
+
+ self.add = TQPushButton( '&Add', self.input )
+ self.add.resize( self.add.sizeHint() )
+ self.grid1.addWidget( self.add, 0, 4 )
+ self.connect( self.add, SIGNAL( 'clicked()' ), self.addEntry )
+
+ self.iFirstName = TQLineEdit( self.input )
+ self.iFirstName.resize( self.iFirstName.sizeHint() )
+ self.grid1.addWidget( self.iFirstName, 1, 0 )
+ self.liFirstName.setBuddy( self.iFirstName )
+
+ self.iLastName = TQLineEdit( self.input )
+ self.iLastName.resize( self.iLastName.sizeHint() )
+ self.grid1.addWidget( self.iLastName, 1, 1 )
+ self.liLastName.setBuddy( self.iLastName )
+
+ self.iAddress = TQLineEdit( self.input )
+ self.iAddress.resize( self.iAddress.sizeHint() )
+ self.grid1.addWidget( self.iAddress, 1, 2 )
+ self.liAddress.setBuddy( self.iAddress )
+
+ self.iEMail = TQLineEdit( self.input )
+ self.iEMail.resize( self.iEMail.sizeHint() )
+ self.grid1.addWidget( self.iEMail, 1, 3 )
+ self.liEMail.setBuddy( self.iEMail )
+
+ self.change = TQPushButton( '&Change', self.input )
+ self.change.resize( self.change.sizeHint() )
+ self.grid1.addWidget( self.change, 1, 4 )
+ self.connect( self.change, SIGNAL( 'clicked()' ), self.changeEntry )
+
+ self.tabWidget.addTab( self.input, '&Add/Change Entry' )
+
+ # --------------------------------------
+
+ self.search = TQWidget( self )
+ self.grid2 = TQGridLayout( self.search, 2, 5, 5, 5 )
+
+ self.cFirstName = TQCheckBox( 'First &Name', self.search )
+ self.cFirstName.resize( self.cFirstName.sizeHint() )
+ self.grid2.addWidget( self.cFirstName, 0, 0 )
+ self.connect( self.cFirstName, SIGNAL( 'clicked()' ), self.toggleFirstName )
+
+ self.cLastName = TQCheckBox( '&Last Name', self.search )
+ self.cLastName.resize( self.cLastName.sizeHint() )
+ self.grid2.addWidget( self.cLastName, 0, 1 )
+ self.connect( self.cLastName, SIGNAL( 'clicked()' ), self.toggleLastName )
+
+ self.cAddress = TQCheckBox( '&Address', self.search )
+ self.cAddress.resize( self.cAddress.sizeHint() )
+ self.grid2.addWidget( self.cAddress, 0, 2 )
+ self.connect( self.cAddress, SIGNAL( 'clicked()' ), self.toggleAddress )
+
+ self.cEMail = TQCheckBox( '&E-Mail', self.search )
+ self.cEMail.resize( self.cEMail.sizeHint() )
+ self.grid2.addWidget( self.cEMail, 0, 3 )
+ self.connect( self.cEMail, SIGNAL( 'clicked()' ), self.toggleEMail )
+
+ self.sFirstName = TQLineEdit( self.search )
+ self.sFirstName.resize( self.sFirstName.sizeHint() )
+ self.grid2.addWidget( self.sFirstName, 1, 0 )
+
+ self.sLastName = TQLineEdit( self.search )
+ self.sLastName.resize( self.sLastName.sizeHint() )
+ self.grid2.addWidget( self.sLastName, 1, 1 )
+
+ self.sAddress = TQLineEdit( self.search )
+ self.sAddress.resize( self.sAddress.sizeHint() )
+ self.grid2.addWidget( self.sAddress, 1, 2 )
+
+ self.sEMail = TQLineEdit( self.search )
+ self.sEMail.resize( self.sEMail.sizeHint() )
+ self.grid2.addWidget( self.sEMail, 1, 3 )
+
+ self.find = TQPushButton( '&Find', self.search )
+ self.find.resize( self.find.sizeHint() )
+ self.grid2.addWidget( self.find, 1, 4 )
+ self.connect( self.find, SIGNAL( 'clicked()' ), self.findEntries )
+
+ self.cFirstName.setChecked( TRUE )
+ self.sFirstName.setEnabled( TRUE )
+ self.sLastName.setEnabled( FALSE )
+ self.sAddress.setEnabled( FALSE )
+ self.sEMail.setEnabled( FALSE )
+
+ self.tabWidget.addTab( self.search, "&Search" )
+
+ self.mainGrid.addWidget( self.tabWidget, 0, 0 )
+
+ def setupListView( self ):
+ self.listView = TQListView( self )
+ self.listView.addColumn( 'First Name' )
+ self.listView.addColumn( 'Last Name' )
+ self.listView.addColumn( 'Address' )
+ self.listView.addColumn( 'E-Mail' )
+
+ self.listView.setSelectionMode( TQListView.Extended )
+
+ self.connect( self.listView, SIGNAL( 'clicked( TQListViewItem* )' ), self.itemSelected )
+
+ self.mainGrid.addWidget( self.listView, 1, 0 )
+ self.listView.setAllColumnsShowFocus( TRUE )
+
+
+ def addEntry( self ):
+ if not self.iFirstName.text().isEmpty() or not self.iLastName.text().isEmpty() or \
+ not self.iAddress.text().isEmpty() or not self.iEMail.text().isEmpty() :
+ self.item = TQListViewItem( self.listView )
+ self.item.setText( 0, self.iFirstName.text() )
+ self.item.setText( 1, self.iLastName.text() )
+ self.item.setText( 2, self.iAddress.text() )
+ self.item.setText( 3, self.iEMail.text() )
+
+ self.iFirstName.setText( '' )
+ self.iLastName.setText( '' )
+ self.iAddress.setText( '' )
+ self.iEMail.setText( '' )
+
+ def changeEntry( self ):
+ self.item = self.listView.currentItem()
+ if self.item and ( not self.iFirstName.text().isEmpty() or not self.iLastName.text().isEmpty() or \
+ not self.iAddress.text().isEmpty() or not self.iEMail.text().isEmpty() ) :
+ self.item.setText( 0, self.iFirstName.text() )
+ self.item.setText( 1, self.iLastName.text() )
+ self.item.setText( 2, self.iAddress.text() )
+ self.item.setText( 3, self.iEMail.text() )
+
+ def selectionChanged( self ):
+ self.iFirstName.setText( '' )
+ self.iLastName.setText( '' )
+ self.iAddress.setText( '' )
+ self.iEMail.setText( '' )
+
+ def itemSelected( self, item ):
+ self.item.setSelected( TRUE )
+ self.item.repaint()
+
+ self.iFirstName.setText( item.text( 0 ) )
+ self.iLastName.setText( item.text( 1 ) )
+ self.iAddress.setText( item.text( 2 ) )
+ self.iEMail.setText( item.text( 3 ) )
+
+ def toggleFirstName( self ):
+ self.sFirstName.setText( '' )
+ if self.cFirstName.isChecked():
+ self.sFirstName.setEnabled( TRUE )
+ self.sFirstName.setFocus()
+ else:
+ self.sFirstName.setEnabled( FALSE )
+
+ def toggleLastName( self ):
+ self.sLastName.setText( '' )
+ if self.cLastName.isChecked():
+ self.sLastName.setEnabled( TRUE )
+ self.sLastName.setFocus()
+ else:
+ self.sLastName.setEnabled( FALSE )
+
+
+ def toggleAddress( self ):
+ self.sAddress.setText( '' )
+ if self.cAddress.isChecked():
+ self.sAddress.setEnabled( TRUE )
+ self.sAddress.setFocus()
+ else:
+ self.sAddress.setEnabled( FALSE )
+
+
+ def toggleEMail( self ):
+ self.sEMail.setText( '' )
+ if self.cEMail.isChecked():
+ self.sEMail.setEnabled( TRUE )
+ self.sEMail.setFocus()
+
+ else:
+ self.sEMail.setEnabled( FALSE )
+
+
+ def findEntries( self ):
+ if not self.cFirstName.isChecked() and not self.cLastName.isChecked() and \
+ not self.cAddress.isChecked() and not self.cEMail.isChecked():
+ self.listView.clearSelection()
+ return
+
+ it = TQListViewItemIterator( self.listView )
+
+ for it in it.current() :
+ select = TRUE
+
+ if self.cFirstName.isChecked():
+ if select and it.current().text( 0 ).contains( self.sFirstName.text() ):
+ select = TRUE
+ else:
+ select = FALSE
+
+ if self.cLastName.isChecked():
+ if select and it.current().text( 1 ).contains( self.sLastName.text() ):
+ select = TRUE
+ else:
+ select = FALSE
+
+ if self.cAddress.isChecked():
+ if select and it.current().text( 2 ).contains( self.sAddress.text() ):
+ select = TRUE
+ else:
+ select = FALSE
+
+ if self.cEMail.isChecked():
+ if select and it.current().text( 3 ).contains( self.sEMail.text() ):
+ select = TRUE
+ else:
+ select = FALSE
+
+
+ if select:
+ it.current().setSelected( TRUE )
+ else:
+ it.current().setSelected( FALSE )
+ it.current().repaint()
+
+
+class ABMainWindow(TQMainWindow):
+ def __init__( self ):
+ TQMainWindow.__init__( self, None, 'example addressbook application' )
+
+ self.filename = TQString.null
+ self.setupMenuBar()
+ self.setupFileTools()
+ self.setupStatusBar()
+ self.setupCentralWidget()
+
+ def setupMenuBar( self ):
+ self.file = TQPopupMenu( self )
+ self.menuBar().insertItem( '&File', self.file )
+
+ openIcon = TQIconSet( TQPixmap( fileopen ) )
+ self.file.insertItem( 'New', self.fileNew, TQt.CTRL + TQt.Key_N )
+ self.file.insertItem( openIcon, 'Open', self.fileOpen, TQt.CTRL + TQt.Key_O )
+ self.file.insertSeparator()
+ saveIcon = TQIconSet( TQPixmap( filesave ) )
+ self.file.insertItem( saveIcon, 'Save', self.fileSave, TQt.CTRL + TQt.Key_S )
+ self.file.insertItem( 'Save As...', self.fileSaveAs )
+ self.file.insertSeparator()
+ printIcon = TQIconSet( TQPixmap( fileprint ) )
+ self.file.insertItem( printIcon, 'Print...', self.filePrint, TQt.CTRL + TQt.Key_P )
+ self.file.insertSeparator()
+ #self.file.insertItem( 'Close', self.closeWindow, TQt.CTRL + TQt.Key_W )
+ self.file.insertItem('Close', self, SLOT('close()'), TQt.CTRL+TQt.Key_W)
+ self.file.insertItem( 'Quit', tqApp, SLOT( 'quit()' ), TQt.CTRL + TQt.Key_Q )
+
+ def setupFileTools( self ):
+ pass
+ #self.fileTools = TQToolBar( self, 'file operations' )
+
+ def setupStatusBar( self ):
+ self.statusBar().message( "Ready", 2000 )
+
+ def setupCentralWidget( self ):
+ self.view = ABCentralWidget( self )
+ #self.view.show()
+ self.setCentralWidget( self.view )
+
+ def closeWindow( self ):
+ close()
+
+
+ def fileNew( self ):
+ pass
+
+ def fileOpen( self ):
+ fn = TQFileDialog.getOpenFileName( TQString.null, TQString.null, self )
+ if not fn.isEmpty():
+ self.filename = fn
+ self.view.load( self.filename )
+
+ def fileSave( self ):
+ if self.filename.isEmpty():
+ self.fileSaveAs()
+ return
+
+ self.view.save( self.filename )
+
+ def fileSaveAs( self ):
+ fn = TQFileDialog.getSaveFileName( TQString.null, TQString.null, self )
+ if not fn.isEmpty():
+ self.filename = fn
+ self.fileSave
+
+ def filePrint( self ):
+ pass
+
+
+a = TQApplication( sys.argv )
+
+mw = ABMainWindow()
+#mw.setupMenuBar()
+#mw.setupFileTools
+#mw.setupStatusBar
+#mw.setupCentralWidget
+#view = ABCentralWidget()
+#mw.setCentralWidget( view )
+mw.setCaption( 'Addressbook 1' )
+a.setMainWidget( mw )
+mw.show()
+
+a.connect( a, SIGNAL( 'lastWindowClosed()' ), a, SLOT( 'quit()' ) )
+a.exec_loop()
diff --git a/examples/application.py b/examples/application.py
new file mode 100755
index 0000000..056e895
--- /dev/null
+++ b/examples/application.py
@@ -0,0 +1,277 @@
+#!/usr/bin/env python
+
+# A simple application.
+
+
+import sys, string
+from python_tqt.qt import *
+
+
+fileopen = [
+ '16 13 5 1',
+ '. c #040404',
+ '# c #808304',
+ 'a c None',
+ 'b c #f3f704',
+ 'c c #f3f7f3',
+ 'aaaaaaaaa...aaaa',
+ 'aaaaaaaa.aaa.a.a',
+ 'aaaaaaaaaaaaa..a',
+ 'a...aaaaaaaa...a',
+ '.bcb.......aaaaa',
+ '.cbcbcbcbc.aaaaa',
+ '.bcbcbcbcb.aaaaa',
+ '.cbcb...........',
+ '.bcb.#########.a',
+ '.cb.#########.aa',
+ '.b.#########.aaa',
+ '..#########.aaaa',
+ '...........aaaaa'
+]
+
+filesave = [
+ '14 14 4 1',
+ '. c #040404',
+ '# c #808304',
+ 'a c #bfc2bf',
+ 'b c None',
+ '..............',
+ '.#.aaaaaaaa.a.',
+ '.#.aaaaaaaa...',
+ '.#.aaaaaaaa.#.',
+ '.#.aaaaaaaa.#.',
+ '.#.aaaaaaaa.#.',
+ '.#.aaaaaaaa.#.',
+ '.##........##.',
+ '.############.',
+ '.##.........#.',
+ '.##......aa.#.',
+ '.##......aa.#.',
+ '.##......aa.#.',
+ 'b.............'
+]
+
+fileprint = [
+ '16 14 6 1',
+ '. c #000000',
+ '# c #848284',
+ 'a c #c6c3c6',
+ 'b c #ffff00',
+ 'c c #ffffff',
+ 'd c None',
+ 'ddddd.........dd',
+ 'dddd.cccccccc.dd',
+ 'dddd.c.....c.ddd',
+ 'ddd.cccccccc.ddd',
+ 'ddd.c.....c....d',
+ 'dd.cccccccc.a.a.',
+ 'd..........a.a..',
+ '.aaaaaaaaaa.a.a.',
+ '.............aa.',
+ '.aaaaaa###aa.a.d',
+ '.aaaaaabbbaa...d',
+ '.............a.d',
+ 'd.aaaaaaaaa.a.dd',
+ 'dd...........ddd'
+]
+
+
+fileOpenText = \
+'''<img source="fileopen">
+Click this button to open a <em>new file</em>.<br><br>
+You can also select the <b>Open</b> command from the <b>File</b> menu.'''
+
+fileSaveText = \
+'''Click this button to save the file you are editing.<br><br>
+You will be prompted for a filename.<br><br>
+You can also select the <b>Save</b> command from the <b>File</b> menu.'''
+
+filePrintText = \
+'''Click this button to print the file you are editing.<br><br>
+You can also select the <b>Print</b> command from the <b>File</b> menu.'''
+
+
+editorList = []
+
+
+class ApplicationWindow(TQMainWindow):
+ def __init__(self):
+ TQMainWindow.__init__(self,None,'example application main window',TQt.WDestructiveClose)
+
+ self.filename = TQString.null
+ self.printer = TQPrinter()
+
+ self.fileTools = TQToolBar(self,'file operations')
+
+ openIcon = TQPixmap(fileopen)
+ self.fileOpen = TQToolButton(TQIconSet(openIcon),'Open File',TQString.null,self.load,self.fileTools,'open file')
+
+ saveIcon = TQPixmap(filesave)
+ self.fileSave = TQToolButton(TQIconSet(saveIcon),'Save File',TQString.null,self.save,self.fileTools,'save file')
+
+ printIcon = TQPixmap(fileprint)
+ self.filePrint = TQToolButton(TQIconSet(printIcon),'Print File',TQString.null,self.printDoc,self.fileTools,'print file')
+
+ TQWhatsThis.whatsThisButton(self.fileTools)
+
+ TQWhatsThis.add(self.fileOpen,fileOpenText)
+ TQMimeSourceFactory.defaultFactory().setPixmap('fileopen',openIcon)
+ TQWhatsThis.add(self.fileSave,fileSaveText)
+ TQWhatsThis.add(self.filePrint,filePrintText)
+
+ self.file = TQPopupMenu(self)
+ self.menuBar().insertItem('&File',self.file)
+
+ self.file.insertItem('&New',self.newDoc,TQt.CTRL + TQt.Key_N)
+
+ id = self.file.insertItem(TQIconSet(openIcon),'&Open',self.load,TQt.CTRL + TQt.Key_O)
+ self.file.setWhatsThis(id,fileOpenText)
+
+ id = self.file.insertItem(TQIconSet(saveIcon),'&Save',self.save,TQt.CTRL + TQt.Key_S)
+ self.file.setWhatsThis(id,fileSaveText)
+
+ id = self.file.insertItem('Save &as',self.saveAs)
+ self.file.setWhatsThis(id,fileSaveText)
+
+ self.file.insertSeparator()
+
+ id = self.file.insertItem(TQIconSet(printIcon),'&Print',self.printDoc,TQt.CTRL + TQt.Key_P)
+ self.file.setWhatsThis(id,filePrintText)
+
+ self.file.insertSeparator()
+
+ self.file.insertItem('&Close',self,SLOT('close()'),TQt.CTRL + TQt.Key_W)
+ self.file.insertItem('&Quit',tqApp,SLOT('closeAllWindows()'),TQt.CTRL + TQt.Key_Q)
+
+ self.help = TQPopupMenu(self)
+ self.menuBar().insertSeparator()
+ self.menuBar().insertItem('&Help',self.help)
+
+ self.help.insertItem('&About',self.about,TQt.Key_F1)
+ self.help.insertItem('About &TQt',self.aboutTQt)
+
+ self.e = TQMultiLineEdit(self,'editor')
+ self.e.setFocus()
+ self.setCentralWidget(self.e)
+
+ self.statusBar().message('Ready',2000)
+ self.resize(450,600)
+
+ def newDoc(self):
+ ed = ApplicationWindow()
+ ed.show()
+ editorList.append(ed)
+
+ def load(self):
+ fn = TQFileDialog.getOpenFileName(TQString.null,TQString.null,self)
+ if fn.isEmpty():
+ self.statusBar().message('Loading aborted',2000)
+ return
+
+ fileName = str(fn)
+
+ self.e.setAutoUpdate(0)
+ self.e.clear()
+
+ try:
+ f = open(fileName,'r')
+ except:
+ return
+
+ for l in f.readlines():
+ self.e.append(l.rstrip())
+
+ f.close()
+
+ self.e.setAutoUpdate(1)
+ self.e.repaint()
+ self.e.setEdited(0)
+ self.setCaption(fileName)
+ self.statusBar().message('Loaded document %s' % (fileName),2000)
+
+ def save(self):
+ if self.filename.isEmpty():
+ self.saveAs()
+ return
+
+ try:
+ f = open(str(self.filename),'w+')
+ except:
+ self.statusBar().message('Could not write to %s' % (self.filename),2000)
+ return
+
+ f.write(str(self.e.text()))
+ f.close()
+
+ self.e.setEdited(0)
+ self.setCaption(self.filename)
+ self.statusBar().message('File %s saved' % (self.filename),2000)
+
+ def saveAs(self):
+ fn = TQFileDialog.getSaveFileName(TQString.null,TQString.null,self)
+ if not fn.isEmpty():
+ self.filename = fn
+ self.save()
+ else:
+ self.statusBar().message('Saving aborted',2000)
+
+ def printDoc(self):
+ Margin = 10
+ pageNo = 1
+
+ if self.printer.setup(self):
+ self.statusBar().message('Printing...')
+
+ p = TQPainter()
+ p.begin(self.printer)
+ p.setFont(self.e.font())
+ yPos = 0
+ fm = p.fontMetrics()
+ metrics = TQPaintDeviceMetrics(self.printer)
+
+ for i in range(self.e.numLines):
+ if Margin + yPos > metrics.height() - Margin:
+ pageNo = pageNo + 1
+ self.statusBar().message('Printing (page %d)...' % (pageNo))
+ self.printer.newPage()
+ yPos = 0
+
+ p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),TQt.ExpandTabs | TQt.DontClip,self.e.textLine(i))
+ yPos = yPos + fm.lineSpacing()
+
+ p.end()
+ self.statusBar().message('Printing completed',2000)
+ else:
+ self.statusBar().message('Printing aborted',2000)
+
+ def closeEvent(self,ce):
+ if not self.e.edited():
+ ce.accept()
+ return
+
+ rc = TQMessageBox.information(self,'TQt Application Example',
+ 'The document has been changed since the last save.',
+ 'Save Now','Cancel','Leave Anyway',0,1)
+
+ if rc == 0:
+ self.save()
+ ce.accept()
+ elif rc == 2:
+ ce.accept()
+ else:
+ ce.ignore()
+
+ def about(self):
+ TQMessageBox.about(self,'TQt Application Example',
+ 'This example demonstrates simple use of TQMainWindow,\nTQMenuBar and TQToolBar.')
+
+ def aboutTQt(self):
+ TQMessageBox.aboutTQt(self,'TQt Application Example')
+
+
+a = TQApplication(sys.argv)
+mw = ApplicationWindow()
+mw.setCaption('Document 1')
+mw.show()
+a.connect(a, SIGNAL('lastWindowClosed()'), a, SLOT('quit()'))
+a.exec_loop()
diff --git a/examples/biff.py b/examples/biff.py
new file mode 100755
index 0000000..abee0cf
--- /dev/null
+++ b/examples/biff.py
@@ -0,0 +1,173 @@
+#!/usr/bin/env python
+
+import os, sys, string
+from python_tqt.qt import *
+
+
+if TQT_VERSION < 0x030100:
+ print("This example requires TQt v3.1.0 or later.")
+ sys.exit(1)
+
+
+FALSE = 0
+TRUE = 1
+
+hasmail_bmp_data = [
+"48 48 3 1",
+" c None",
+". c #000000",
+"+ c #FFFFFF",
+"................................................",
+".............................++++++++++.........",
+".............................++++++++++.........",
+"........................++++.+++.+.+.++.........",
+"......................++++.++++.+.+.+++.........",
+".....................+++.....+++.+.+.++.........",
+"....................++.......++.+.+.+++.........",
+"...................++........++++++++++.........",
+"..................++.........++++++++++.........",
+".................++..........+++..+.............",
+"................++...........+++..+.............",
+"...............++............+++.++.............",
+"..............+++++++........++++++.............",
+".............++++++++++......++++++.............",
+"............+++......+++.....++++.+.............",
+"...........+++.........++....+++..+.............",
+"...........++..........++...++++..+.............",
+"..........++............++.+++++..+.............",
+"..........++............++++++++..+.............",
+".........++....++++++....+++.+++..+.............",
+".........++......++......++..+++..+.............",
+".........++..............++..+++..+.............",
+".........++..............++..+++..+.............",
+".........++..............++..++...+.............",
+"+++++++..++.+.+..+..+.+..++.......+..+++++++++++",
+".........++.+++.+.+.+.+..++.......+.............",
+".........++.+.+.+++.+.+..++.......+.............",
+".........++.+.+.+.+.+.+..++......++.............",
+".........++.+.+.+.+.+.++.++.....++..............",
+".........++..............++....++...............",
+"..+.+.+..++..............++...++..+.+.+.+.+.+.+.",
+".+.+.+.+.++..............++..++..+.+.+.+.+.+.+..",
+"..+.+.+..++..............++.++..+.+.+.+.+.+.+.+.",
+".+.+.+.+.++..............+++++.+.+.+.+.+.+.+.+..",
+"..+.+.+..+++++++++++++++++++.++.+.+.+.+.+.+.+.+.",
+".+.+.+.+..+++++++++++++++++..+.+.+.+.+.+.+.+.+..",
+"..+.+.+.+..........+...+.....++.+.+.+.+.+.+.+.+.",
+".+.+.+.+.+.+.+.+.+.+...+.....+.+.+.+.+.+.+.+.+..",
+"..+.+.+.+.+.+.+.+.++...+.....++.+.+.+.+.+.+.+.+.",
+".+.+.+.+.+.+.+.+.+.+...+.....+.+.+.+.+.+.+.+.+..",
+"..+.+.+.+.+.+.+.+.++...+.....++.+.+.+.+.+.+.+.+.",
+".+.+.+.+.+.+.+.+.+.+...+.....+.+.+.+.+.+.+.+.+..",
+"..+.+.+.+.+.+.+.+.++...+....+.+.+.+.+.+.+.+.+.+.",
+".+.+.+.+.+.+.+.+.+.+...+...+.+.+.+.+.+.+.+.+.+..",
+"..+.+.+.+.+.+.+.+.+.+..+..+.+.+.+.+.+.+.+.+.+.+.",
+".+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+..",
+"..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+...",
+"................................................"
+]
+
+nomail_bmp_data = [
+"48 48 3 1",
+" c None",
+". c #FFFFFF",
+"+ c #000000",
+"................................................",
+"................................................",
+"................................................",
+".........................++++...................",
+".......................++++++++.................",
+".....................++++....+++................",
+"....................+++........++...............",
+"...................++...........++..............",
+"..................++............++..............",
+".................++..............++.......+.....",
+"................++...............++......++.....",
+"...............++................++.....+++.....",
+"..............+++++++...........+++....++++.....",
+".............++++++++++........++++...+++++.....",
+"............+++......+++......+++.+..++++++.....",
+"...........+++.........++....+++..+.+++.+++.....",
+"...........++..........++...+++...++++..+++.....",
+"..........++............++.+++...++++...++......",
+"..........++............+++++...++++............",
+".........++....++++++....+++...++++.............",
+".........++......++......++...+++.+.............",
+".........++..............++...+++.+.............",
+".........++..............++...++..+.............",
+".........++..............++.......+.............",
+"+++++++..++..............++.......+..+++++++++++",
+".........++..............++.......+.............",
+".........++..............++.......+.............",
+".........++..............++......++.............",
+".........++..............++.....++..............",
+".........++..............++....++...............",
+".........++..............++...++................",
+".........++..............++..++.................",
+".........++..............++.++..................",
+".........++..............+++++..................",
+".........+++++++++++++++++++.+..................",
+"..........+++++++++++++++++..+..................",
+"...................+...+.....+..................",
+"...................+...+.....+..................",
+"...................+...+.....+..................",
+"...................+...+.....+..................",
+"...................+...+.....+..................",
+"...................+...+.....+..................",
+"...................+...+.....+..................",
+"...................+...+.....+..................",
+"+++.++++++++++.+.+++...+..+++++++++++.++...+++++",
+"+.+++..+++.+.+++++.++..+.++.+++..+..+.++.+.++++.",
+".++...+.....++...+...+++++++....+....++++++...+.",
+"++++++++++++++++++++++++++++++++++++++++++++++++"
+]
+
+class Biff(TQWidget):
+ def __init__(self):
+ TQWidget.__init__(self, None, "Biff - example application")
+
+ mail = os.getenv("MAIL")
+ fi = TQFileInfo(mail);
+ if not fi.exists():
+ s = "/var/spool/mail/"+os.getenv("USER")
+ fi.setFile(s)
+
+ if fi.exists():
+ self.mailbox = fi.absFilePath()
+ self.startTimer(1000)
+
+ self.setMinimumSize(48, 48)
+ self.setMaximumSize(48, 48)
+ self.resize(48, 48)
+
+ self.hasNewMail = TQPixmap(hasmail_bmp_data)
+ self.noNewMail = TQPixmap(nomail_bmp_data)
+
+ self.gotMail = FALSE
+ self.lastModified = fi.lastModified()
+
+ def timerEvent(self, te):
+ fi = TQFileInfo(self.mailbox)
+ newState = ( fi.lastModified().toTime_t() != self.lastModified.toTime_t() and fi.lastModified().toTime_t() > fi.lastRead().toTime_t())
+ if newState != self.gotMail:
+ if self.gotMail == TRUE:
+ self.lastModified = fi.lastModified()
+ self.gotMail = newState
+ self.repaint(FALSE)
+
+ def paintEvent(self, pe):
+ if self.gotMail:
+ bitBlt(self, 0, 0, self.hasNewMail)
+ else:
+ bitBlt(self, 0, 0, self.noNewMail)
+
+ def mousePressEvent(self, me):
+ fi = TQFileInfo(self.mailbox)
+ lastModified = fi.lastModified()
+
+
+a = TQApplication(sys.argv)
+b = Biff()
+a.setMainWidget(b)
+b.show()
+a.exec_loop()
diff --git a/examples/bigtable.py b/examples/bigtable.py
new file mode 100755
index 0000000..f2d9788
--- /dev/null
+++ b/examples/bigtable.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: bigtable.py,v 1.1 2002/06/19 07:56:07 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+import os
+from python_tqt.qt import *
+from python_tqt.qttable import *
+
+TRUE = 1
+FALSE = 0
+
+numRows = 1000000
+numCols = 1000000
+
+class MyTable(TQTable):
+ def __init__(self, r, c):
+ TQTable.__init__(self, r, c)
+ self.items = {}
+ self.widgets = {}
+ self.setCaption("This is a big table with 1.000.000x1.000.000 cells...")
+ self.setLeftMargin(self.fontMetrics().width("W999999W"))
+
+ def resizeData(self, v):
+ return
+
+ def item(self, r, c):
+ try:
+ return self.items[self.indexOf(r, c)]
+ except KeyError:
+ return None
+
+ def setItem(self, r, c, i):
+ self.items[self.indexOf(r, c)] = i
+
+ def clearCell(self, r, c):
+ try:
+ del self.items[self.indexOf(r, c)]
+ except KeyError:
+ pass
+
+ def insertWidget(self, r, c, w):
+ self.widgets[self.indexOf(r, c)] = w
+
+ def cellWidget(self, r, c):
+ try:
+ return self.widgets[self.indexOf(r, c)]
+ except KeyError:
+ return None
+
+ def clearCellWidget(self, r, c):
+ try:
+ del self.widgets[self.indexOf(r, c)]
+ except KeyError:
+ pass
+
+
+if __name__ == '__main__':
+ app = TQApplication(sys.argv)
+
+ table = MyTable(numRows, numCols)
+ app.setMainWidget(table)
+ table.show()
+ app.exec_loop()
diff --git a/examples/buttongroups.py b/examples/buttongroups.py
new file mode 100755
index 0000000..3d6883e
--- /dev/null
+++ b/examples/buttongroups.py
@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+#/****************************************************************************
+#** $Id: buttongroups.py,v 1.2 2002/12/20 18:46:10 phil Exp $
+#**
+#** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+#**
+#** This file is part of an example program for TQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+
+TRUE = 1
+FALSE = 0
+
+##
+# Creates all child widgets of the ButtonGroups window
+##
+
+class ButtonsGroups( TQWidget ):
+ def __init__( self, *args ):
+ TQWidget.__init__(*(self,) + args)
+
+ # Create Widgets which allow easy layouting
+ self.vbox = TQVBoxLayout( self, 11, 6 )
+ self.box1 = TQHBoxLayout( self.vbox )
+ self.box2 = TQHBoxLayout( self.vbox )
+
+ # ------- first group
+
+ # Create an exclusive button group
+ self.grp1 = TQButtonGroup( 1, TQGroupBox.Horizontal, "Button Group 1 (exclusive)", self )
+ self.box1.addWidget( self.grp1 )
+ self.grp1.setExclusive( TRUE )
+
+ # insert 3 radiobuttons
+ self.rb11 = TQRadioButton( "&Radiobutton 1", self.grp1 )
+ self.rb11.setChecked( TRUE )
+ TQRadioButton( "R&adiobutton 2", self.grp1 )
+ TQRadioButton( "Ra&diobutton 3", self.grp1 )
+
+ # ------- second group
+
+ # Create a non-exclusive buttongroup
+ self.grp2 = TQButtonGroup( 1, TQGroupBox.Horizontal, "Button Group 2 (non-exclusive)", self )
+ self.box1.addWidget( self.grp2 )
+ self.grp2.setExclusive( FALSE )
+
+ # insert 3 checkboxes
+ TQCheckBox( "&Checkbox 1", self.grp2 )
+ self.cb12 = TQCheckBox( "C&heckbox 2", self.grp2 )
+ self.cb12.setChecked( TRUE )
+ self.cb13 = TQCheckBox( "Triple &State Button", self.grp2 )
+ self.cb13.setTristate( TRUE )
+ self.cb13.setChecked( TRUE )
+
+ # ------------ third group
+
+ # create a buttongroup which is exclusive for radiobuttons and non-exclusive for all other buttons
+ self.grp3 = TQButtonGroup( 1, TQGroupBox.Horizontal, "Button Group 3 (Radiobutton-exclusive)", self )
+ self.box2.addWidget( self.grp3 )
+ self.grp3.setRadioButtonExclusive( TRUE )
+
+ # insert three radiobuttons
+ self.rb21 = TQRadioButton( "Rad&iobutton 1", self.grp3 )
+ self.rb22 = TQRadioButton( "Radi&obutton 2", self.grp3 )
+ self.rb23 = TQRadioButton( "Radio&button 3", self.grp3 )
+ self.rb23.setChecked( TRUE )
+
+ # insert a checkbox...
+ self.state = TQCheckBox( "E&nable Radiobuttons", self.grp3 )
+ self.state.setChecked( TRUE )
+ # ...and connect its SIGNAL clicked() with the SLOT slotChangeGrp3State()
+ self.connect( self.state, SIGNAL( "clicked()" ), self.slotChangeGrp3State )
+
+ # ------------ fourth group
+
+ # create a groupbox which layouts its childs in a columns
+ self.grp4 = TQButtonGroup( 1, TQGroupBox.Horizontal, "Groupbox with normal buttons", self )
+ self.box2.addWidget( self.grp4 )
+
+ # insert two pushbuttons...
+ TQPushButton( "&Push Button", self.grp4 )
+ self.tb2 = TQPushButton( "&Toggle Button", self.grp4 )
+
+ # ... and make the second one a toggle button
+ self.tb2.setToggleButton( TRUE )
+ self.tb2.setOn( TRUE )
+
+ # ... and make the third one a flat button
+ self.tb3 = TQPushButton( "&Flat Button", self.grp4 )
+ self.tb3.setFlat( TRUE )
+
+ # .. and the fourth a button with a menu
+ self.tb4 = TQPushButton( "Popup Button", self.grp4 )
+ menu = TQPopupMenu(self.tb4)
+ menu.insertItem("Item1", 0)
+ menu.insertItem("Item2", 0)
+ menu.insertItem("Item3", 0)
+ menu.insertItem("Item4", 0)
+ self.tb4.setPopup(menu)
+
+ #
+ # SLOT slotChangeGrp3State()
+ # enables/disables the radiobuttons of the third buttongroup
+ #
+
+ def slotChangeGrp3State( self ):
+ self.rb21.setEnabled( self.state.isChecked() )
+ self.rb22.setEnabled( self.state.isChecked() )
+ self.rb23.setEnabled( self.state.isChecked() )
+
+
+## main program
+a = TQApplication( sys.argv )
+
+buttonsgroups = ButtonsGroups()
+buttonsgroups.resize( 500, 250 )
+buttonsgroups.setCaption( "PyQT Example - Buttons and Groups" )
+a.setMainWidget( buttonsgroups )
+buttonsgroups.show()
+
+a.exec_loop()
diff --git a/examples/canvas/butterfly.png b/examples/canvas/butterfly.png
new file mode 100644
index 0000000..619f253
--- /dev/null
+++ b/examples/canvas/butterfly.png
Binary files differ
diff --git a/examples/canvas/canvas.py b/examples/canvas/canvas.py
new file mode 100755
index 0000000..5f7f774
--- /dev/null
+++ b/examples/canvas/canvas.py
@@ -0,0 +1,619 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtcanvas import *
+import random
+
+
+True = 1
+False = 0
+butterfly_fn = TQString.null
+butterflyimg = []
+logo_fn = TQString.null
+logoimg = []
+bouncy_logo = None
+views = []
+
+
+class ImageItem(TQCanvasRectangle):
+ def __init__(self,img,canvas):
+ TQCanvasRectangle.__init__(self,canvas)
+ self.imageRTTI=984376
+ self.image=img
+ self.pixmap=TQPixmap()
+ self.setSize(self.image.width(), self.image.height())
+ self.pixmap.convertFromImage(self.image, TQt.OrderedAlphaDither);
+
+ def rtti(self):
+ return self.imageRTTI
+
+ def hit(self,p):
+ ix = p.x()-self.x()
+ iy = p.y()-self.y()
+ if not self.image.valid( ix , iy ):
+ return False
+ self.pixel = self.image.pixel( ix, iy )
+ return (tqAlpha( self.pixel ) != 0)
+
+ def drawShape(self,p):
+ p.drawPixmap( self.x(), self.y(), self.pixmap )
+
+
+class NodeItem(TQCanvasEllipse):
+ def __init__(self,canvas):
+ TQCanvasEllipse.__init__(self,6,6,canvas)
+ self.__inList=[]
+ self.__outList=[]
+ self.setPen(TQPen(TQt.black))
+ self.setBrush(TQBrush(TQt.red))
+ self.setZ(128)
+
+ def addInEdge(self,edge):
+ self.__inList.append(edge)
+
+ def addOutEdge(self,edge):
+ self.__outList.append(edge)
+
+ def moveBy(self,dx,dy):
+ TQCanvasEllipse.moveBy(self,dx,dy)
+ for each_edge in self.__inList:
+ each_edge.setToPoint( int(self.x()), int(self.y()) )
+ for each_edge in self.__outList:
+ each_edge.setFromPoint( int(self.x()), int(self.y()) )
+
+class EdgeItem(TQCanvasLine):
+ __c=0
+ def __init__(self,fromNode, toNode,canvas):
+ TQCanvasLine.__init__(self,canvas)
+ self.__c=self.__c+1
+ self.setPen(TQPen(TQt.black))
+ self.setBrush(TQBrush(TQt.red))
+ fromNode.addOutEdge(self)
+ toNode.addInEdge(self)
+ self.setPoints(int(fromNode.x()),int(fromNode.y()), int(toNode.x()), int(toNode.y()))
+ self.setZ(127)
+
+ def setFromPoint(self,x,y):
+ self.setPoints(x,y,self.endPoint().x(),self.endPoint().y())
+
+ def setToPoint(self,x,y):
+ self.setPoints(self.startPoint().x(), self.startPoint().y(),x,y)
+
+ def count(self):
+ return self.__c
+
+ def moveBy(self,dx,dy):
+ pass
+
+
+class FigureEditor(TQCanvasView):
+ def __init__(self,c,parent,name,f):
+ TQCanvasView.__init__(self,c,parent,name,f)
+ self.__moving=0
+ self.__moving_start= 0
+
+ def contentsMousePressEvent(self,e): # TQMouseEvent e
+ point = self.inverseWorldMatrix().map(e.pos())
+ ilist = self.canvas().collisions(point) #TQCanvasItemList ilist
+ for each_item in ilist:
+ if each_item.rtti()==984376:
+ if not each_item.hit(point):
+ continue
+ self.__moving=each_item
+ self.__moving_start=point
+ return
+ self.__moving=0
+
+ def clear(self):
+ ilist = self.canvas().allItems()
+ for each_item in ilist:
+ if each_item:
+ each_item.setCanvas(None)
+ del each_item
+ self.canvas().update()
+
+ def contentsMouseMoveEvent(self,e):
+ if self.__moving :
+ point = self.inverseWorldMatrix().map(e.pos());
+ self.__moving.moveBy(point.x() - self.__moving_start.x(),point.y() - self.__moving_start.y())
+ self.__moving_start = point
+ self.canvas().update()
+
+
+class BouncyLogo(TQCanvasSprite):
+ def __init__(self,canvas):
+ # Make sure the logo exists.
+ global bouncy_logo
+ if bouncy_logo is None:
+ bouncy_logo=TQCanvasPixmapArray("qt-trans.xpm")
+
+ TQCanvasSprite.__init__(self,None,canvas)
+ self.setSequence(bouncy_logo)
+ self.setAnimated(True)
+ self.initPos()
+ self.logo_rtti=1234
+
+ def rtti(self):
+ return self.logo_rtti
+
+ def initPos(self):
+ self.initSpeed()
+ trial=1000
+ self.move(random.random()%self.canvas().width(), random.random()%self.canvas().height())
+ self.advance(0)
+ trial=trial-1
+ while (trial & (self.xVelocity()==0 )& (self.yVelocity()==0)):
+ elf.move(random.random()%self.canvas().width(), random.random()%self.canvas().height())
+ self.advance(0)
+ trial=trial-1
+
+ def initSpeed(self):
+ speed=4.0
+ d=random.random()%1024/1024.0
+ self.setVelocity(d*speed*2-speed, (1-d)*speed*2-speed)
+
+ def advance(self,stage):
+ if stage==0:
+ vx=self.xVelocity()
+ vy=self.yVelocity()
+ if (vx==0.0) & (vy==0.0):
+ self.initSpeed()
+ vx=self.xVelocity()
+ vy=self.yVelocity()
+
+ nx=self.x()+vx
+ ny=self.y()+vy
+
+ if (nx<0) | (nx >= self.canvas().width()):
+ vx=-vx
+ if (ny<0) | (ny >= self.canvas().height()):
+ vy=-vy
+
+ for bounce in [0,1,2,3]:
+ l=self.collisions(False)
+ for hit in l:
+ if (hit.rtti()==1234) & (hit.collidesWith(self)):
+ if bounce==0:
+ vx=-vx
+ elif bounce==1:
+ vy=-vy
+ vx=-vx
+ elif bounce==2:
+ vx=-vx
+ elif bounce==3:
+ vx=0
+ vy=0
+ self.setVelocity(vx,vy)
+ break
+
+ if (self.x()+vx < 0) | (self.x()+vx >= self.canvas().width()):
+ vx=0
+ if (self.y()+vy < 0) | (self.y()+vy >= self.canvas().height()):
+ vy=0
+
+ self.setVelocity(vx,vy)
+ elif stage==1:
+ TQCanvasItem.advance(self,stage)
+
+
+class Main (TQMainWindow):
+ def __init__(self,c,parent,name,f=0):
+ TQMainWindow.__init__(self,parent,name,f)
+ self.editor=FigureEditor(c,self,name,f)
+ self.printer=TQPrinter()
+ self.dbf_id=0
+ self.canvas=c
+ self.mainCount=0
+ file=TQPopupMenu(self.menuBar())
+ file.insertItem("&Fill canvas", self.init, TQt.CTRL+TQt.Key_F)
+ file.insertItem("&Erase canvas", self.clear, TQt.CTRL+TQt.Key_E)
+ file.insertItem("&New view", self.newView, TQt.CTRL+TQt.Key_N)
+ file.insertSeparator();
+ file.insertItem("&Print", self._print, TQt.CTRL+TQt.Key_P)
+ file.insertSeparator()
+ file.insertItem("E&xit", tqApp, SLOT("quit()"), TQt.CTRL+TQt.Key_Q)
+ self.menuBar().insertItem("&File", file)
+
+ edit = TQPopupMenu(self.menuBar() )
+ edit.insertItem("Add &Circle", self.addCircle, TQt.ALT+TQt.Key_C)
+ edit.insertItem("Add &Hexagon", self.addHexagon, TQt.ALT+TQt.Key_H)
+ edit.insertItem("Add &Polygon", self.addPolygon, TQt.ALT+TQt.Key_P)
+ edit.insertItem("Add Spl&ine", self.addSpline, TQt.ALT+TQt.Key_I)
+ edit.insertItem("Add &Text", self.addText, TQt.ALT+TQt.Key_T)
+ edit.insertItem("Add &Line", self.addLine, TQt.ALT+TQt.Key_L)
+ edit.insertItem("Add &Rectangle", self.addRectangle, TQt.ALT+TQt.Key_R)
+ edit.insertItem("Add &Sprite", self.addSprite, TQt.ALT+TQt.Key_S)
+ edit.insertItem("Create &Mesh", self.addMesh, TQt.ALT+TQt.Key_M )
+ edit.insertItem("Add &Alpha-blended image", self.addButterfly, TQt.ALT+TQt.Key_A)
+ self.menuBar().insertItem("&Edit", edit)
+
+ view = TQPopupMenu(self.menuBar() );
+ view.insertItem("&Enlarge", self.enlarge, TQt.SHIFT+TQt.CTRL+TQt.Key_Plus);
+ view.insertItem("Shr&ink", self.shrink, TQt.SHIFT+TQt.CTRL+TQt.Key_Minus);
+ view.insertSeparator();
+ view.insertItem("&Rotate clockwise", self.rotateClockwise, TQt.CTRL+TQt.Key_PageDown);
+ view.insertItem("Rotate &counterclockwise", self.rotateCounterClockwise, TQt.CTRL+TQt.Key_PageUp);
+ view.insertItem("&Zoom in", self.zoomIn, TQt.CTRL+TQt.Key_Plus);
+ view.insertItem("Zoom &out", self.zoomOut, TQt.CTRL+TQt.Key_Minus);
+ view.insertItem("Translate left", self.moveL, TQt.CTRL+TQt.Key_Left);
+ view.insertItem("Translate right", self.moveR, TQt.CTRL+TQt.Key_Right);
+ view.insertItem("Translate up", self.moveU, TQt.CTRL+TQt.Key_Up);
+ view.insertItem("Translate down", self.moveD, TQt.CTRL+TQt.Key_Down);
+ view.insertItem("&Mirror", self.mirror, TQt.CTRL+TQt.Key_Home);
+ self.menuBar().insertItem("&View", view)
+
+ self.options = TQPopupMenu( self.menuBar() );
+ self.dbf_id = self.options.insertItem("Double buffer", self.toggleDoubleBuffer)
+ self.options.setItemChecked(self.dbf_id, True)
+ self.menuBar().insertItem("&Options",self.options)
+
+ self.menuBar().insertSeparator();
+
+ help = TQPopupMenu( self.menuBar() )
+ help.insertItem("&About", self.help, TQt.Key_F1)
+ help.insertItem("&About TQt", self.aboutTQt, TQt.Key_F2)
+ help.setItemChecked(self.dbf_id, True)
+ self.menuBar().insertItem("&Help",help)
+
+ self.statusBar()
+
+ self.setCentralWidget(self.editor)
+
+ self.printer = 0
+ self.tb=0
+ self.tp=0
+
+ self.init()
+
+ def init(self):
+ self.clear()
+ r=24
+ r=r+1
+ random.seed(r)
+ for i in range(self.canvas.width()/56):
+ self.addButterfly()
+ for j in range(self.canvas.width()/85):
+ self.addHexagon()
+ for k in range(self.canvas.width()/128):
+ self.addLogo()
+
+ def newView(self):
+ m=Main(self.canvas,None,"new windiw",TQt.WDestructiveClose)
+ tqApp.setMainWidget(m)
+ m.show()
+ tqApp.setMainWidget(None)
+ views.append(m)
+
+ def clear(self):
+ self.editor.clear()
+
+ def help(self):
+ TQMessageBox.information(None, "PyTQt Canvas Example",
+ "<h3>The PyTQt TQCanvas classes example</h3><hr>"
+ "<p>This is the PyTQt implementation of "
+ "TQt canvas example.</p> by Sadi Kose "
+ "<i>(kose@nuvox.net)</i><hr>"
+ "<ul>"
+ "<li> Press ALT-S for some sprites."
+ "<li> Press ALT-C for some circles."
+ "<li> Press ALT-L for some lines."
+ "<li> Drag the objects around."
+ "<li> Read the code!"
+ "</ul>","Dismiss")
+
+ def aboutTQt(self):
+ TQMessageBox.aboutTQt(self,"PyTQt Canvas Example")
+
+ def toggleDoubleBuffer(self):
+ s = not self.options.isItemChecked(self.dbf_id)
+ self.options.setItemChecked(self.dbf_id,s)
+ self.canvas.setDoubleBuffering(s)
+
+ def enlarge(self):
+ self.canvas.resize(self.canvas.width()*4/3, self.canvas.height()*4/3)
+
+ def shrink(self):
+ self.canvas.resize(self.canvas.width()*3/4, self.canvas.height()*3/4)
+
+ def rotateClockwise(self):
+ m = self.editor.worldMatrix()
+ m.rotate( 22.5 )
+ self.editor.setWorldMatrix( m )
+
+ def rotateCounterClockwise(self):
+ m = self.editor.worldMatrix()
+ m.rotate( -22.5 )
+ self.editor.setWorldMatrix( m )
+
+ def zoomIn(self):
+ m = self.editor.worldMatrix()
+ m.scale( 2.0, 2.0 )
+ self.editor.setWorldMatrix( m )
+
+ def zoomOut(self):
+ m = self.editor.worldMatrix()
+ m.scale( 0.5, 0.5 )
+ self.editor.setWorldMatrix( m )
+
+ def mirror(self):
+ m = self.editor.worldMatrix()
+ m.scale( -1, 1 )
+ self.editor.setWorldMatrix( m )
+
+ def moveL(self):
+ m = self.editor.worldMatrix()
+ m.translate( -16, 0 )
+ self.editor.setWorldMatrix( m )
+
+ def moveR(self):
+ m = self.editor.worldMatrix()
+ m.translate( +16, 0 )
+ self.editor.setWorldMatrix( m )
+
+ def moveU(self):
+ m = self.editor.worldMatrix()
+ m.translate( 0, -16 )
+ self.editor.setWorldMatrix( m )
+
+ def moveD(self):
+ m = self.editor.worldMatrix();
+ m.translate( 0, +16 );
+ self.editor.setWorldMatrix( m )
+
+ def _print(self):
+ if not self.printer:
+ self.printer = TQPrinter()
+ if self.printer.setup(self) :
+ pp=TQPainter(self.printer)
+ self.canvas.drawArea(TQRect(0,0,self.canvas.width(),self.canvas.height()),pp,False)
+
+ def addSprite(self):
+ i = BouncyLogo(self.canvas)
+ i.setZ(256*random.random()%256);
+ i.show();
+
+ def addButterfly(self):
+ if butterfly_fn.isEmpty():
+ return
+ if not butterflyimg:
+ butterflyimg.append(TQImage())
+ butterflyimg[0].load(butterfly_fn)
+ butterflyimg.append(TQImage())
+ butterflyimg[1] = butterflyimg[0].smoothScale( int(butterflyimg[0].width()*0.75),
+ int(butterflyimg[0].height()*0.75) )
+ butterflyimg.append(TQImage())
+ butterflyimg[2] = butterflyimg[0].smoothScale( int(butterflyimg[0].width()*0.5),
+ int(butterflyimg[0].height()*0.5) )
+ butterflyimg.append(TQImage())
+ butterflyimg[3] = butterflyimg[0].smoothScale( int(butterflyimg[0].width()*0.25),
+ int(butterflyimg[0].height()*0.25) )
+
+ i = ImageItem(butterflyimg[int(4*random.random()%4)],self.canvas)
+ i.move((self.canvas.width()-butterflyimg[0].width())*random.random()%(self.canvas.width()-butterflyimg[0].width()),
+ (self.canvas.height()-butterflyimg[0].height())*random.random()%(self.canvas.height()-butterflyimg[0].height()))
+ i.setZ(256*random.random()%256+250);
+ i.show()
+
+ def addLogo(self):
+ if logo_fn.isEmpty():
+ return;
+ if not logoimg:
+ logoimg.append(TQImage())
+ logoimg[0].load( logo_fn )
+ logoimg.append(TQImage())
+ logoimg[1] = logoimg[0].smoothScale( int(logoimg[0].width()*0.75),
+ int(logoimg[0].height()*0.75) )
+ logoimg.append(TQImage())
+ logoimg[2] = logoimg[0].smoothScale( int(logoimg[0].width()*0.5),
+ int(logoimg[0].height()*0.5) )
+ logoimg.append(TQImage())
+ logoimg[3] = logoimg[0].smoothScale( int(logoimg[0].width()*0.25),
+ int(logoimg[0].height()*0.25) );
+
+ i = ImageItem(logoimg[int(4*random.random()%4)],self.canvas)
+ i.move((self.canvas.width()-logoimg[0].width())*random.random()%(self.canvas.width()-logoimg[0].width()),
+ (self.canvas.height()-logoimg[0].width())*random.random()%(self.canvas.height()-logoimg[0].width()))
+ i.setZ(256*random.random()%256+256)
+ i.show()
+
+ def addCircle(self):
+ i = TQCanvasEllipse(50,50,self.canvas)
+ i.setBrush( TQBrush(TQColor(256*random.random()%32*8,256*random.random()%32*8,256*random.random()%32*8) ))
+ i.move(self.canvas.width()*random.random()%self.canvas.width(),self.canvas.width()*random.random()%self.canvas.height())
+ i.setZ(256*random.random()%256)
+ i.show()
+
+ def addHexagon(self):
+ i = TQCanvasPolygon(self.canvas)
+ size = canvas.width() / 25
+ pa=TQPointArray(6)
+ pa.setPoint(0,TQPoint(2*size,0))
+ pa.setPoint(1,TQPoint(size,-size*173/100))
+ pa.setPoint(2,TQPoint(-size,-size*173/100))
+ pa.setPoint(3,TQPoint(-2*size,0))
+ pa.setPoint(4,TQPoint(-size,size*173/100))
+ pa.setPoint(5,TQPoint(size,size*173/100))
+ i.setPoints(pa)
+ i.setBrush( TQBrush(TQColor(256*random.random()%32*8,256*random.random()%32*8,256*random.random()%32*8) ))
+ i.move(self.canvas.width()*random.random()%self.canvas.width(),self.canvas.width()*random.random()%self.canvas.height())
+ i.setZ(256*random.random()%256)
+ i.show()
+
+ def addPolygon(self):
+ i = TQCanvasPolygon(self.canvas)
+ size = self.canvas.width()/2
+ pa=TQPointArray(6)
+ pa.setPoint(0, TQPoint(0,0))
+ pa.setPoint(1, TQPoint(size,size/5))
+ pa.setPoint(2, TQPoint(size*4/5,size))
+ pa.setPoint(3, TQPoint(size/6,size*5/4))
+ pa.setPoint(4, TQPoint(size*3/4,size*3/4))
+ pa.setPoint(5, TQPoint(size*3/4,size/4))
+
+ i.setPoints(pa)
+ i.setBrush(TQBrush( TQColor(256*random.random()%32*8,256*random.random()%32*8,256*random.random()%32*8)) )
+ i.move(self.canvas.width()*random.random()%self.canvas.width(),self.canvas.width()*random.random()%self.canvas.height())
+ i.setZ(256*random.random()%256)
+ i.show()
+
+ def addSpline(self):
+ i = TQCanvasSpline(self.canvas)
+ size = canvas.width()/6
+ pa=TQPointArray(12)
+ pa.setPoint(0,TQPoint(0,0))
+ pa.setPoint(1,TQPoint(size/2,0))
+ pa.setPoint(2,TQPoint(size,size/2))
+ pa.setPoint(3,TQPoint(size,size))
+ pa.setPoint(4,TQPoint(size,size*3/2))
+ pa.setPoint(5,TQPoint(size/2,size*2))
+ pa.setPoint(6,TQPoint(0,size*2))
+ pa.setPoint(7,TQPoint(-size/2,size*2))
+ pa.setPoint(8,TQPoint(size/4,size*3/2))
+ pa.setPoint(9,TQPoint(0,size))
+ pa.setPoint(10,TQPoint(-size/4,size/2))
+ pa.setPoint(11,TQPoint(-size/2,0))
+ i.setControlPoints(pa)
+ i.setBrush( TQBrush(TQColor(256*random.random()%32*8,256*random.random()%32*8,256*random.random()%32*8) ))
+ i.move(self.canvas.width()*random.random()%self.canvas.width(),self.canvas.width()*random.random()%self.canvas.height())
+ i.setZ(256*random.random()%256)
+ i.show()
+
+ def addText(self):
+ i = TQCanvasText(self.canvas)
+ i.setText("TQCanvasText")
+ i.move(self.canvas.width()*random.random()%self.canvas.width(),self.canvas.width()*random.random()%self.canvas.height())
+ i.setZ(256*random.random()%256)
+ i.show()
+
+ def addLine(self):
+ i = TQCanvasLine(self.canvas);
+ i.setPoints( self.canvas.width()*random.random()%self.canvas.width(), self.canvas.width()*random.random()%self.canvas.height(),
+ self.canvas.width()*random.random()%self.canvas.width(), self.canvas.width()*random.random()%self.canvas.height() )
+ i.setPen( TQPen(TQColor(256*random.random()%32*8,256*random.random()%32*8,256*random.random()%32*8), 6) )
+ i.setZ(256*random.random()%256)
+ i.show()
+
+ def ternary(self,exp,x,y):
+ if exp:
+ return x
+ else:
+ return y
+
+ def addMesh(self):
+ x0 = 0;
+ y0 = 0;
+
+ if not self.tb:
+ self.tb = TQBrush( TQt.red )
+ if not self.tp:
+ self.tp = TQPen( TQt.black )
+
+ nodecount = 0;
+
+ w = self.canvas.width()
+ h = self.canvas.height()
+
+ dist = 30
+ rows = h / dist
+ cols = w / dist
+
+ #ifndef TQT_NO_PROGRESSDIALOG
+ #progress=TQProgressDialog( "Creating mesh...", "Abort", rows,
+ # self, "progress", True );
+ #endif
+
+ lastRow=[]
+ for c in range(cols):
+ lastRow.append(NodeItem(self.canvas))
+ for j in range(rows):
+ n = self.ternary(j%2 , cols-1 , cols)
+ prev = 0;
+ for i in range(n):
+ el = NodeItem( self.canvas )
+ nodecount=nodecount+1
+ r = 20*20*random.random()
+ xrand = r %20
+ yrand = (r/20) %20
+ el.move( xrand + x0 + i*dist + self.ternary(j%2 , dist/2 , 0 ),
+ yrand + y0 + j*dist );
+
+ if j > 0 :
+ if i < cols-1 :
+ EdgeItem( lastRow[i], el, self.canvas ).show()
+ if j%2 :
+ EdgeItem( lastRow[i+1], el, self.canvas ).show()
+ elif i > 0 :
+ EdgeItem( lastRow[i-1], el, self.canvas ).show()
+ if prev:
+ EdgeItem( prev, el, self.canvas ).show()
+
+ if i > 0 :
+ lastRow[i-1] = prev
+ prev = el
+ el.show()
+
+ lastRow[n-1]=prev
+ #ifndef TQT_NO_PROGRESSDIALOG
+ #progress.setProgress( j )
+ #if progress.wasCancelled() :
+ # break
+ #endif
+
+ #ifndef TQT_NO_PROGRESSDIALOG
+ #progress.setProgress( rows )
+ #endif
+ #// tqDebug( "%d nodes, %d edges", nodecount, EdgeItem::count() );
+
+ def addRectangle(self):
+ i = TQCanvasRectangle( self.canvas.width()*random.random()%self.canvas.width(),
+ self.canvas.width()*random.random()%self.canvas.height(),
+ self.canvas.width()/5,self.canvas.width()/5,self.canvas)
+ z = 256*random.random()%256
+ i.setBrush( TQBrush(TQColor(z,z,z) ))
+ i.setPen( TQPen(TQColor(self.canvas.width()*random.random()%32*8,
+ self.canvas.width()*random.random()%32*8,
+ self.canvas.width()*random.random()%32*8), 6) )
+ i.setZ(z)
+ i.show()
+
+
+if __name__=='__main__':
+ app=TQApplication(sys.argv)
+
+ if len(sys.argv) > 1:
+ butterfly_fn=TQString(sys.argv[1])
+ else:
+ butterfly_fn=TQString("butterfly.png")
+
+ if len(sys.argv) > 2:
+ logo_fn = TQString(sys.argv[2])
+ else:
+ logo_fn=TQString("qtlogo.png")
+
+ canvas=TQCanvas(800,600)
+ canvas.setAdvancePeriod(30)
+ m=Main(canvas,None,"pyqt canvas example")
+ m.resize(m.sizeHint())
+
+ tqApp.setMainWidget(m)
+ m.setCaption("TQt Canvas Example ported to PyTQt")
+ if TQApplication.desktop().width() > m.width() + 10 and TQApplication.desktop().height() > m.height() + 30:
+ m.show()
+ else:
+ m.showMaximized()
+
+ m.show();
+ #// m.help();
+ tqApp.setMainWidget(None);
+
+ TQObject.connect( tqApp, SIGNAL("lastWindowClosed()"), tqApp, SLOT("quit()") )
+
+ app.exec_loop()
+
+ # We need to explicitly delete the canvas now (and, therefore, the main
+ # window beforehand) to make sure that the sprite logo doesn't get garbage
+ # collected first.
+ views = []
+ del m
+ del canvas
diff --git a/examples/canvas/qt-trans.xpm b/examples/canvas/qt-trans.xpm
new file mode 100644
index 0000000..225f684
--- /dev/null
+++ b/examples/canvas/qt-trans.xpm
@@ -0,0 +1,54 @@
+/* XPM */
+static char *qtlogo_xpm[] = {
+/* width height ncolors chars_per_pixel */
+"54 34 13 1",
+/* colors */
+" c #000000",
+". c #999999",
+"X c #333366",
+"o c #6666CC",
+"O c #333333",
+"@ c #666699",
+"# c #000066",
+"$ c #666666",
+"% c #3333CC",
+"& c #000033",
+"* c #9999CC",
+"= c #333399",
+"+ c None",
+/* pixels */
+"+++++++++++++++++++.$OOO$.++++++++++++++++++++++++++++",
+"+++++++++++++++++$ O.+++++++++++++++++++++++++",
+"+++++++++++++++.O $++++++++++++++++++++++++",
+"++++++++++++++. $.++.$ O+++++++++++++++++++++++",
+"+++++++++++++. O.+++++++$ O++++++++++++++++++++++",
+"+++++++++++++O ++++++++++$ $+++++++++++++++++++++",
+"++++++++++++$ .+++++++++++O .++++++++++++++++++++",
+"+++++++++++. O+++++++++++++ O++++++.+++++++++++++",
+"+++++++++++$ .+++++++++++++$ .+++.O +++++++++++++",
+"+++++++++++ +++++++++++++++ O+++. +++++++++++++",
+"++++++++++. &Xoooo*++++++++++$ +++. +++++++++++++",
+"++++++++++@=%%%%%%%%%%*+++++++. .++. +++++++++++++",
+"+++++++**oooooo**++*o%%%%o+++++ $++O +++++++++++++",
+"+++++*****$OOX@oooo*++*%%%%%*++O $+. OOO$++++++++*",
+"++..+.++....$O$+*ooooo*+*o%%%%%O O+$ $$O.++++++**+",
+"***+*+++++$$....+++*oooo**+*o%%# O++O ++++++***o*++",
+"*+++++++++O $.....++**oooo**+*X &o*O ++++*ooo*++++",
+"++++++++++$ O++.....++**oooo*X &%%& ..*o%%*++++++",
+"++++++++++$ ++++.....+++**ooO $*o& @oo*+++++++++",
+"++++++++++. .++++++.....+++*O Xo*O .++++++++++++",
+"+++++++++++ O+++++++++...... .++O +++++++++++++",
+"+++++++++++O +++.$$$.++++++. O+++O +++++++++++++",
+"+++++++++++. $$OO O.++++O .+++O +++++++++++++",
+"++++++++++++O .+++.O $++. O++++O +++++++++++++",
+"++++++++++++. O+++++O $+O +++++O +++++++++++++",
+"+++++++++++++. O+++++O O .+++++O .++++++++++++",
+"++++++++++++++$ .++++O .++++.+$ O+.$.++++++++",
+"+++++++++++++++. O$$O .+++++... +++++++++",
+"+++++++++++++++++$ O+++++$$+.O O$.+++++++++",
+"+++++++++++++++++++$OO O$.O O.++. .++++++++++++++++",
+"+++++++++++++++++++++++++++. OO .++++++++++++++++",
+"++++++++++++++++++++++++++++. O+++++++++++++++++",
+"+++++++++++++++++++++++++++++. .+++++++++++++++++",
+"++++++++++++++++++++++++++++++.O O.++++++++++++++++++"
+};
diff --git a/examples/canvas/qtlogo.png b/examples/canvas/qtlogo.png
new file mode 100644
index 0000000..96202de
--- /dev/null
+++ b/examples/canvas/qtlogo.png
Binary files differ
diff --git a/examples/checklists.py b/examples/checklists.py
new file mode 100755
index 0000000..61734ba
--- /dev/null
+++ b/examples/checklists.py
@@ -0,0 +1,135 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2002 Oleksandr Yakovlyev (yshurik) <yshurik@thekompany.com>
+
+import sys
+from python_tqt.qt import *
+
+TRUE = 1
+FALSE = 0
+
+class CheckLists(TQWidget):
+ def __init__(self, *args):
+ TQWidget.__init__(* (self, ) + args )
+
+ lay = TQHBoxLayout(self)
+ lay.setMargin(5)
+
+ vbox1 = TQVBoxLayout(lay)
+ vbox1.setMargin(5)
+
+ # First child: a Label
+ vbox1.addWidget(TQLabel("Check some items!", self))
+
+ # Second child: the ListView
+ self.lv1 = TQListView(self)
+ vbox1.addWidget(self.lv1)
+ self.lv1.addColumn("Items")
+ self.lv1.setRootIsDecorated(TRUE)
+
+ # create a list with 4 ListViewItems which will be parent items of other ListViewItems
+
+ parentList = []
+
+ parentList.append( TQListViewItem( self.lv1, "Parent Item 1" ) )
+ parentList.append( TQListViewItem( self.lv1, "Parent Item 2" ) )
+ parentList.append( TQListViewItem( self.lv1, "Parent Item 3" ) )
+ parentList.append( TQListViewItem( self.lv1, "Parent Item 4" ) )
+
+ num = 0
+
+ self.childList1 = []
+ # go through the list of parent items...
+ for i in range(4):
+ it = parentList[i]
+ it.setOpen( TRUE )
+
+ # ...and create 5 checkable child ListViewItems for each parent item
+ for j in range(5):
+ ci = TQCheckListItem( it, TQString("%1. Child of Parent %2").arg( j ).arg( i ), TQCheckListItem.CheckBox )
+ self.childList1.append(ci)
+
+ # Create another widget for layouting
+ tmp1 = TQVBoxLayout( lay )
+ tmp1.setMargin( 5 )
+
+ # create a pushbutton
+ copy1 = TQPushButton( " -> ", self )
+ tmp1.addWidget( copy1 )
+ copy1.setMaximumWidth( copy1.sizeHint().width() );
+ # connect the SIGNAL clicked() of the pushbutton with the SLOT copy1to2()
+ self.connect( copy1, SIGNAL('clicked()'), self.copy1to2 )
+
+ # another widget for layouting
+ vbox2 = TQVBoxLayout( lay )
+ vbox2.setMargin( 5 )
+
+ # and another label
+ vbox2.addWidget( TQLabel( "Check one item!", self ) )
+
+ # create the second listview
+ self.lv2 = TQListView( self )
+ vbox2.addWidget( self.lv2 )
+ self.lv2.addColumn( "Items" )
+ self.lv2.setRootIsDecorated( TRUE )
+
+ # another widget needed for layouting only
+ tmp2 = TQVBoxLayout( lay )
+ tmp2.setMargin( 5 )
+
+ # create another pushbutton...
+ copy2 = TQPushButton( " -> ", self )
+ lay.addWidget( copy2 )
+ copy2.setMaximumWidth( copy2.sizeHint().width() )
+ # ...and connect its clicked() SIGNAL to the copy2to3() SLOT
+ self.connect( copy2, SIGNAL('clicked()'), self.copy2to3 )
+
+ tmp3 = TQVBoxLayout( lay )
+ tmp3.setMargin( 5 )
+
+ # and create a label which will be at the right of the window
+ self.label = TQLabel( "No Item yet...", self )
+ tmp3.addWidget( self.label )
+
+ def copy1to2(self):
+ self.lv2.clear()
+
+ # Insert first a controller Item into the second ListView. Always if Radio-ListViewItems
+ # are inserted into a Listview, the parent item of these MUST be a controller Item!
+ item = TQCheckListItem( self.lv2, "Controller", TQCheckListItem.Controller )
+ item.setOpen( TRUE )
+
+ self.listChild2 = []
+ for it in self.childList1:
+ # ...check state of childs, and...
+ if it.parent() != None:
+ # ...if the item is checked...
+ if it.isOn():
+ # ...insert a Radio-ListViewItem with the same text into the second ListView
+ ri = TQCheckListItem(item , it.text(0), TQCheckListItem.RadioButton)
+ self.listChild2.append(ri)
+
+ if item.firstChild() != None:
+ item.firstChild().setOn(TRUE)
+
+ def copy2to3(self):
+ self.label.setText( "No Item checked" )
+
+ # iterate through the second ListView...
+ for it in self.listChild2:
+ # ...check state of childs, and...
+ if it.parent() != None:
+ # ...if the item is checked...
+ if it.isOn():
+ # ...set the text of the item to the label
+ self.label.setText( it.text( 0 ) )
+
+a = TQApplication(sys.argv)
+
+checkLists = CheckLists()
+checkLists.resize(700, 400)
+checkLists.setCaption("PyTQt example - CheckLists")
+
+a.setMainWidget(checkLists)
+checkLists.show()
+a.exec_loop()
diff --git a/examples/cursor.py b/examples/cursor.py
new file mode 100755
index 0000000..da9db7b
--- /dev/null
+++ b/examples/cursor.py
@@ -0,0 +1,114 @@
+#!/usr/bin/env python
+
+"""$Id: cursor.py,v 1.1 2003/07/01 14:18:37 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+
+# cb_bits and cm_bits were generated by X bitmap program.
+
+cb_width = 32
+cb_height = 32
+
+# cursor bitmap
+cb_bits = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x0f\x00" \
+ b"\x00\x06\x30\x00\x80\x01\xc0\x00\x40\x00\x00\x01" \
+ b"\x20\x00\x00\x02\x10\x00\x00\x04\x08\x3e\x3e\x08" \
+ b"\x08\x03\xe0\x08\xc4\x00\x00\x11\x04\x1e\x78\x10" \
+ b"\x02\x0c\x30\x20\x02\x40\x00\x20\x02\x40\x00\x20" \
+ b"\x02\x40\x00\x20\x02\x20\x04\x20\x02\x20\x04\x20" \
+ b"\x02\x10\x08\x20\x02\x08\x08\x20\x02\xf0\x07\x20" \
+ b"\x04\x00\x00\x10\x04\x00\x00\x10\x08\x00\xc0\x08" \
+ b"\x08\x3c\x30\x08\x10\xe6\x19\x04\x20\x00\x0f\x02" \
+ b"\x40\x00\x00\x01\x80\x01\xc0\x00\x00\x06\x30\x00" \
+ b"\x00\xf8\x0f\x00\x00\x00\x00\x00"
+
+cm_width = 32
+cm_height = 32
+
+# cursor bitmap mask
+cm_bits = b"\x00\x00\x00\x00\x00\xf8\x1f\x00\x00\xfe\x3f\x00" \
+ b"\x80\x07\xf0\x00\xc0\x01\xc0\x01\x60\x00\x00\x03" \
+ b"\x30\x00\x00\x06\x18\x00\x00\x0c\x0c\x3e\x3e\x18" \
+ b"\x0e\x03\xe0\x18\xc6\x00\x00\x31\x07\x1e\x78\x30" \
+ b"\x03\x0c\x30\x60\x03\x40\x00\x60\x03\x40\x00\x60" \
+ b"\x03\x40\x00\x60\x03\x20\x04\x60\x03\x20\x04\x60" \
+ b"\x03\x10\x08\x60\x03\x08\x08\x60\x03\xf0\x07\x60" \
+ b"\x06\x00\x00\x30\x06\x00\x00\x30\x0c\x00\xc0\x18" \
+ b"\x0c\x3c\x30\x18\x18\xe6\x19\x0c\x30\x00\x0f\x06" \
+ b"\x60\x00\x00\x03\xc0\x01\xc0\x01\x80\x07\xf0\x00" \
+ b"\x00\xfe\x3f\x00\x00\xf8\x0f\x00"
+
+# The CursorView contains many labels with different cursors.
+class CursorView( TQWidget ): # cursor view
+ def __init__( self ):
+ TQWidget.__init__( self )
+ # Constructs a cursor view.
+#enum CursorShape { ArrowCursor, UpArrowCursor, CrossCursor, WaitCursor, IbeamCursor, SizeVerCursor, SizeHorCursor, SizeBDiagCursor, SizeFDiagCursor, SizeAllCursor, BlankCursor, SplitVCursor, SplitHCursor, PointingHandCursor, ForbiddenCursor, WhatsThisCursor, LastCursor = WhatsThisCursor, BitmapCursor = 24 }
+
+ shape = [
+ "ArrowCursor", "UpArrowCursor", "CrossCursor",
+ "WaitCursor", "IbeamCursor", "SizeVerCursor",
+ "SizeHorCursor", "SizeBDiagCursor", "SizeFDiagCursor",
+ "SizeAllCursor", "BlankCursor", "SplitVCursor",
+ "SplitHCursor", "PointingHandCursor", "ForbiddenCursor",
+ "WhatsThisCursor"
+ ]
+ name = [
+ "standard arrow cursor", "upwards arrow",
+ "crosshair", "hourglass/watch",
+ "ibeam/text entry", "vertical resize",
+ "horizontal resize", "diagonal resize (/)",
+ "diagonal resize (\)", "all directions resize",
+ "blank/invisible cursor", "vertical splitting",
+ "horziontal splitting", "a pointing hand",
+ "a slashed circle", "an arrow with a question mark"
+ ]
+
+ self.setCaption( "CursorView" ) # set window caption
+
+ grid = TQGridLayout( self, 5, 4, 20 )
+
+ i=0
+ for y in range( 0, 4, 1 ) : # create the small labels
+ for x in range( 0, 4, 1 ) :
+ label = TQLabel( self )
+ label.setCursor( TQCursor(i) )
+ label.setText( shape[i] );
+ label.setAlignment( self.AlignCenter )
+ label.setFrameStyle( TQFrame.Box | TQFrame.Raised )
+ grid.addWidget( label, x, y )
+ TQToolTip.add( label, name[i] )
+ i += 1
+
+ cb = TQBitmap( cb_width, cb_height, cb_bits, True )
+ cm = TQBitmap( cm_width, cm_height, cm_bits, True )
+ custom = TQCursor( cb, cm ) # create bitmap cursor
+
+ label = TQLabel( self ) # create the big label
+ label.setCursor( custom )
+ label.setText( "Custom bitmap cursor" )
+ TQToolTip.add( label, "custom bitmap cursor" )
+ label.setAlignment( self.AlignCenter )
+ label.setFrameStyle( TQFrame.Box | TQFrame.Sunken )
+ grid.addMultiCellWidget( label, 4, 4, 0, 3 )
+
+# Create and display a CursorView.
+def main( args ):
+ a = TQApplication(sys.argv) # application object
+ v = CursorView() # cursor view
+ v.setCaption( "TQt Example - Cursors" )
+ a.setMainWidget( v )
+ v.show()
+
+ a.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/dclock.py b/examples/dclock.py
new file mode 100755
index 0000000..302d454
--- /dev/null
+++ b/examples/dclock.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+
+# A port to PyTQt of the dclock example from TQt v2.x.
+
+
+import sys, string
+from python_tqt.qt import *
+
+
+class DigitalClock(TQLCDNumber):
+ def __init__(self, parent=None, name=None):
+ TQLCDNumber.__init__(self, parent, name)
+ self.showingColon = 0
+ self.setFrameStyle(TQFrame.Panel | TQFrame.Raised)
+ self.setLineWidth(2)
+ self.showTime()
+ self.normalTimer = self.startTimer(500)
+ self.showDateTimer = -1
+
+ def timerEvent(self, e):
+ if e.timerId() == self.showDateTimer:
+ self.stopDate()
+ else:
+ if self.showDateTimer == -1:
+ self.showTime()
+
+ def mousePressEvent(self, e):
+ if e.button() == TQt.LeftButton:
+ self.showDate()
+
+ def showDate(self):
+ if self.showDateTimer != -1:
+ return
+ d = TQDate.currentDate()
+ self.display('%2d %2d' % (d.month(), d.day()))
+ self.showDateTimer = self.startTimer(2000)
+
+ def stopDate(self):
+ self.killTimer(self.showDateTimer)
+ self.showDateTimer = -1
+ self.showTime()
+
+ def showTime(self):
+ self.showingColon = not self.showingColon
+ s = list(str(TQTime.currentTime().toString())[:5]) #.left(5)
+ if not self.showingColon:
+ s[2] = ' '
+ if s[0] == '0':
+ s[0] = ' '
+ s = ''.join(s)
+ self.display(s)
+
+a = TQApplication(sys.argv)
+clock = DigitalClock()
+clock.resize(170,80)
+a.setMainWidget(clock)
+clock.show()
+a.exec_loop()
diff --git a/examples/desktop.py b/examples/desktop.py
new file mode 100755
index 0000000..154b632
--- /dev/null
+++ b/examples/desktop.py
@@ -0,0 +1,230 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+
+seed = 0.353535353535
+KINDA_RAND_MAX = 32767
+
+def kindaRand():
+ global seed
+ seed = seed * 147
+ seed = seed - int(seed)
+ return int(seed*(KINDA_RAND_MAX + 1))
+
+velmax = 15
+velmin = 4
+
+def velocity(i):
+ if i == 1 or i == 2:
+ i = (kindaRand()&0x7fff % velmax)/3 + velmin
+ else:
+ i = (kindaRand()&0x7fff % velmax) + velmin
+ return i
+
+maxpoints = 5
+maxcurves = 8
+
+def poly():
+ d = TQApplication.desktop()
+ d.setEraseColor(TQt.white)
+ xvel = [ 0 ] * maxpoints
+ yvel = [ 0 ] * maxpoints
+ head = 0
+ tail = -maxcurves + 2
+ a = [ TQPointArray() ] * maxcurves
+ r = d.rect()
+ for i in range(maxcurves):
+ a[i].resize(maxpoints)
+ p = a[0]
+ for i in range(maxpoints):
+ p.setPoint(i, (kindaRand()&0x7fff) % r.width(),
+ (kindaRand()&0x7fff) % r.height() )
+ xvel[i] = velocity(i)
+ yvel[i] = velocity(i)
+
+ paint = TQPainter()
+ paint.begin(d)
+
+ for ntimes in range(2000):
+ paint.setBrush(TQColor(kindaRand()%360,180,255, TQColor.Hsv))
+ paint.drawPolygon(a[head])
+ tail = tail + 1
+ if tail >= maxcurves:
+ tail = 0
+ minx = r.left()
+ maxx = r.right()
+ miny = r.top()
+ maxy = r.bottom()
+ p = a[head]
+ head = head + 1
+ if head >= maxcurves:
+ head = 0
+ for i in range(maxpoints):
+ x, y = p.point(i)
+ x = x + xvel[i]
+ y = y + yvel[i]
+ if x >= maxx:
+ x = maxx - (x - maxx + 1)
+ xvel[i] = -velocity(i)
+ if x <= minx:
+ x = minx + (minx - x + 1)
+ xvel[i] = velocity(i)
+ if y >= maxy:
+ y = maxy - (y - maxy + 1)
+ yvel[i] = -velocity(i)
+ if y <= miny:
+ y = miny + (miny - y + 1)
+ yvel[i] = velocity(i)
+ a[head].setPoint(i, x, y)
+ paint.end()
+
+def rotate():
+ w = 64
+ h = 64
+ image = TQImage(w, h, 8, 128)
+ for i in range(128):
+ image.setColor(i, tqRgb(i,0,0))
+ for y in range(h):
+ for x in range(w):
+ image.setPixel(x,y,(x+y)%128)
+
+ pm = TQPixmap()
+ pm.convertFromImage(image)
+ pm.setOptimization(TQPixmap.BestOptim)
+
+ d = TQApplication.desktop()
+
+ for i in range(0,361,2):
+ m = TQWMatrix()
+ m.rotate(i)
+ rpm = pm.xForm(m)
+ d.setErasePixmap(rpm)
+ d.update()
+
+def generateStone(pm, c1, c2, c3):
+ p = TQPainter()
+ p1 = TQPen(c1, 0)
+ p2 = TQPen(c2, 0)
+ p3 = TQPen(c3, 0)
+
+ p.begin(pm)
+ for i in range(pm.width()):
+ for j in range(pm.height()):
+ r = kindaRand()
+ if r < KINDA_RAND_MAX / 3:
+ p.setPen(p1)
+ elif r < KINDA_RAND_MAX / 3 * 2:
+ p.setPen(p2)
+ else:
+ p.setPen(p3)
+ p.drawPoint(i, j)
+ p.end()
+
+def drawShadeText(p, x, y, text, topColor, bottomColor, sw=2):
+ if not p.isActive():
+ return
+
+ p.setPen(bottomColor)
+ p.drawText(x+sw, y+sw, text)
+ p.setPen(topColor)
+ p.drawText(x, y, text)
+
+class DesktopWidget(TQWidget):
+ def __init__(self, s, parent=None, name=''):
+ TQWidget.__init__(self, parent, name, TQt.WType_Desktop | TQt.WPaintDesktop)
+ self.text = s
+ self.pm = None
+
+ def paintEvent(self, pe):
+ c1 = self.eraseColor()
+ c2 = c1.light(104)
+ c3 = c1.dark(106)
+ if not self.pm:
+ self.pm = TQPixmap(64, 64)
+ generateStone(self.pm, c1, c2, c3)
+ self.setErasePixmap(self.pm)
+ self.update()
+ br = self.fontMetrics().boundingRect(self.text)
+ offscreen = TQPixmap(br.width(), br.height())
+ x = self.width()/2 - br.width()/2
+ y = self.height()/2 - br.height()/2
+ offscreen.fill(self, x, y)
+ p = TQPainter()
+ p.begin(offscreen)
+ drawShadeText(p, -br.x(), -br.y(), self.text, c2, c3, 3)
+ p.end()
+ bitBlt(self, x, y, offscreen)
+
+def desktopWidget(s='Trolltech'):
+ t = DesktopWidget(s)
+ t.update()
+ tqApp.exec_loop()
+
+def desktopText(s='Trolltech'):
+ border = 20
+
+ c1 = tqApp.palette().normal().background()
+ c2 = c1.light(104)
+ c3 = c1.dark(106)
+
+ pm = TQPixmap(10, 10)
+ p = TQPainter()
+ p.begin(pm)
+ r = p.fontMetrics().boundingRect(s)
+ p.end()
+
+ appWidth = tqApp.desktop().width()
+ appHeight = tqApp.desktop().height()
+ if r.width() > appWidth - border*2:
+ r.setWidth(appWidth - border*2)
+ if r.height() > appHeight - border*2:
+ r.setHeight(appHeight - border*2)
+
+ pm.resize(r.size().width()+border*2,r.size().height()+border*2)
+ generateStone(pm, c1, c2, c3)
+ p.begin(pm)
+ drawShadeText(p, -r.x()+border, -r.y()+border, s, c2, c3)
+ p.end()
+
+ tqApp.desktop().setErasePixmap(pm)
+
+a = TQApplication(sys.argv)
+if len(sys.argv) > 1:
+ f = TQFont('charter', 96, TQFont.Black)
+ f.setStyleHint(TQFont.Times)
+ a.setFont(f)
+
+validOptions = 0
+
+if len(sys.argv) == 2:
+ validOptions = 1
+ if sys.argv[1] == '-poly':
+ poly()
+ elif sys.argv[1] == '-rotate':
+ rotate()
+ elif sys.argv[1] == '-troll':
+ desktopText()
+ elif sys.argv[1] == '-trollwidget':
+ desktopWidget()
+ else:
+ validOptions = 0
+
+if len(sys.argv) == 3:
+ validOptions = 1
+ if sys.argv[1] == '-shadetext':
+ desktopText(sys.argv[2])
+ elif sys.argv[1] == '-shadewidget':
+ desktopWidget(sys.argv[2])
+ else:
+ validOptions = 0
+
+if not validOptions:
+ print("""Usage:
+\tdesktop -poly
+\tdesktop -rotate
+\tdesktop -troll
+\tdesktop -trollwidget
+\tdesktop -shadetext <text>
+\tdesktop -shadewidget <text>""")
+ rotate()
diff --git a/examples/dirview.py b/examples/dirview.py
new file mode 100755
index 0000000..e6b1f58
--- /dev/null
+++ b/examples/dirview.py
@@ -0,0 +1,452 @@
+#!/usr/bin/env python
+
+"""**************************************************************************
+** $Id: dirview.py,v 1.7 2005/11/14 17:21:26 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+** Some corrections by M. Biermaier (http://www.office-m.at)
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+
+folder_closed_xpm = [
+ "16 16 9 1",
+ "g c #808080",
+ "b c #c0c000",
+ "e c #c0c0c0",
+ "# c #000000",
+ "c c #ffff00",
+ ". c None",
+ "a c #585858",
+ "f c #a0a0a4",
+ "d c #ffffff",
+ "..###...........",
+ ".#abc##.........",
+ ".#daabc#####....",
+ ".#ddeaabbccc#...",
+ ".#dedeeabbbba...",
+ ".#edeeeeaaaab#..",
+ ".#deeeeeeefe#ba.",
+ ".#eeeeeeefef#ba.",
+ ".#eeeeeefeff#ba.",
+ ".#eeeeefefff#ba.",
+ ".##geefeffff#ba.",
+ "...##gefffff#ba.",
+ ".....##fffff#ba.",
+ ".......##fff#b##",
+ ".........##f#b##",
+ "...........####."
+]
+
+folder_open_xpm = [
+ "16 16 11 1",
+ "# c #000000",
+ "g c #c0c0c0",
+ "e c #303030",
+ "a c #ffa858",
+ "b c #808080",
+ "d c #a0a0a4",
+ "f c #585858",
+ "c c #ffdca8",
+ "h c #dcdcdc",
+ "i c #ffffff",
+ ". c None",
+ "....###.........",
+ "....#ab##.......",
+ "....#acab####...",
+ "###.#acccccca#..",
+ "#ddefaaaccccca#.",
+ "#bdddbaaaacccab#",
+ ".eddddbbaaaacab#",
+ ".#bddggdbbaaaab#",
+ "..edgdggggbbaab#",
+ "..#bgggghghdaab#",
+ "...ebhggghicfab#",
+ "....#edhhiiidab#",
+ "......#egiiicfb#",
+ "........#egiibb#",
+ "..........#egib#",
+ "............#ee#"
+]
+
+folder_locked = [
+ "16 16 10 1",
+ "h c #808080",
+ "b c #ffa858",
+ "f c #c0c0c0",
+ "e c #c05800",
+ "# c #000000",
+ "c c #ffdca8",
+ ". c None",
+ "a c #585858",
+ "g c #a0a0a4",
+ "d c #ffffff",
+ "..#a#...........",
+ ".#abc####.......",
+ ".#daa#eee#......",
+ ".#ddf#e##b#.....",
+ ".#dfd#e#bcb##...",
+ ".#fdccc#daaab#..",
+ ".#dfbbbccgfg#ba.",
+ ".#ffb#ebbfgg#ba.",
+ ".#ffbbe#bggg#ba.",
+ ".#fffbbebggg#ba.",
+ ".##hf#ebbggg#ba.",
+ "...###e#gggg#ba.",
+ ".....#e#gggg#ba.",
+ "......###ggg#b##",
+ ".........##g#b##",
+ "...........####."
+]
+
+pix_file = [
+ "16 16 7 1",
+ "# c #000000",
+ "b c #ffffff",
+ "e c #000000",
+ "d c #404000",
+ "c c #c0c000",
+ "a c #ffffc0",
+ ". c None",
+ "................",
+ ".........#......",
+ "......#.#a##....",
+ ".....#b#bbba##..",
+ "....#b#bbbabbb#.",
+ "...#b#bba##bb#..",
+ "..#b#abb#bb##...",
+ ".#a#aab#bbbab##.",
+ "#a#aaa#bcbbbbbb#",
+ "#ccdc#bcbbcbbb#.",
+ ".##c#bcbbcabb#..",
+ "...#acbacbbbe...",
+ "..#aaaacaba#....",
+ "...##aaaaa#.....",
+ ".....##aa#......",
+ ".......##......."
+]
+
+folderLocked = None
+folderClosed = None
+folderOpened = None
+fileNormal = None
+
+class FileItem( TQListViewItem ) :
+ def __init__( self, parent=None, s1=TQString.null, s2=TQString.null ):
+ TQListViewItem.__init__( self, parent, s1, s2 )
+ self.pix = None
+
+ def setPixmap( self, p ) :
+ self.pix = p
+ self.setup()
+ self.widthChanged( 0 )
+ self.invalidateHeight()
+ self.repaint()
+
+ def pixmap( self, i ) :
+ if i : return None
+ else : return self.pix;
+
+# Class Directory
+class Directory( TQListViewItem ) :
+ def __init__( self, parent=None, filename=TQString.null, col2=TQString.null ):
+ TQListViewItem.__init__( self, parent, filename, col2 )
+ self.pix = None
+ global folderLocked, folderClosed, folderOpened, fileNormal
+ self.showDirsOnly = False
+ if isinstance(parent, TQListView):
+ self.p = None
+ self.showDirsOnly = parent.showDirsOnly()
+ self.f = TQFile( TQString('/') )
+ else:
+ self.p = parent
+ self.showDirsOnly = parent.showDirsOnly
+ self.f = TQFile( TQString(filename) )
+
+ self.readable = TQDir( self.fullName() ).isReadable()
+ if not self.readable : self.setPixmap( folderLocked )
+ else : self.setPixmap( folderClosed )
+
+ def setPixmap( self, px ) :
+ self.pix = px
+ self.setup()
+ self.widthChanged( 0 )
+ self.invalidateHeight()
+ self.repaint()
+
+ def pixmap( self, i ) :
+ if i : return None
+ else : return self.pix
+
+ def setOpen( self, o ) :
+ if o : self.setPixmap( folderOpened )
+ else : self.setPixmap( folderClosed )
+
+ if o and not self.childCount() :
+ s = TQString( self.fullName() )
+ thisDir = TQDir( s )
+ if not thisDir.isReadable() :
+ self.readable = False
+ self.setExpandable( False )
+ return
+
+ self.listView().setUpdatesEnabled( False )
+ files = thisDir.entryInfoList()
+ if files :
+ fi = TQFileInfo()
+ for it in files:
+ fi = it
+ if str(fi.fileName()) == "." or str(fi.fileName()) == ".." :
+ continue # nothing
+ elif fi.isSymLink() and not self.showDirsOnly :
+ item = FileItem( self, fi.fileName(), "Symbolic Link" )
+ item.setPixmap( fileNormal )
+ elif fi.isDir() :
+ Directory( self, fi.fileName() )
+ elif not self.showDirsOnly :
+ if fi.isFile() : item = FileItem( self, fi.fileName(), "File" )
+ else : item = FileItem( self, fi.fileName(), "Special" )
+ item.setPixmap( fileNormal )
+
+ self.listView().setUpdatesEnabled( True )
+ TQListViewItem.setOpen( self, o )
+
+ def setup( self ):
+ self.setExpandable( True )
+ TQListViewItem.setup( self )
+
+ def fullName( self ):
+ s = TQString()
+ if self.p :
+ s = self.p.fullName()
+ s.append( self.f.name() )
+ s.append( "/" )
+ else :
+ s = self.f.name()
+ return s
+
+ def text( self, column ) :
+ if column == 0 : return self.f.name()
+ elif self.readable : return "Directory"
+ else : return "Unreadable Directory"
+
+# Class DirectoryView
+
+class DirectoryView( TQListView ):
+ def __init__( self, parent=None, name=None, sdo=False ):
+ TQListView.__init__( self, parent, name )
+ self.dirsOnly = sdo
+ self.oldCurrent = 0
+ self.dropItem = 0
+ self.presspos = TQPoint(0,0)
+ self.mousePressed = False
+ global folderLocked, folderClosed, folderOpened, fileNormal #= TQPixmap()
+ self.autoopenTime = 750
+
+ self.autoopen_timer = TQTimer( self )
+ if not folderLocked :
+ folderLocked = TQPixmap( folder_locked )
+ folderClosed = TQPixmap( folder_closed_xpm )
+ folderOpened = TQPixmap( folder_open_xpm )
+ fileNormal = TQPixmap( pix_file )
+
+ self.connect( self, SIGNAL("doubleClicked(TQListViewItem *)"),
+ self.slotFolderSelected )
+ self.connect( self, SIGNAL("returnPressed(TQListViewItem *)"),
+ self.slotFolderSelected )
+
+ self.setAcceptDrops( True )
+ self.viewport().setAcceptDrops( True )
+
+ self.connect( self.autoopen_timer, SIGNAL("timeout()"), self.openFolder )
+
+ def showDirsOnly( self ):
+ return self.dirsOnly
+
+ def slotFolderSelected( self, i ):
+ if not i or not self.showDirsOnly():
+ return
+ dir = i
+ self.emit( PYSIGNAL("folderSelected(const TQString &)"), (dir.fullName(), ) )
+
+ def openFolder( self ):
+ self.autoopen_timer.stop()
+ if self.dropItem and not self.dropItem.isOpen():
+ self.dropItem.setOpen( True )
+ self.dropItem.repaint()
+
+ def contentsDragEnterEvent( self, e ):
+ if not TQUriDrag.canDecode(e) :
+ e.ignore()
+ return
+ self.oldCurrent = self.currentItem()
+ i = self.itemAt( self.contentsToViewport(e.pos()) )
+ if i :
+ self.dropItem = i
+ self.autoopen_timer.start( self.autoopenTime )
+
+ def contentsDragMoveEvent( self, e ) :
+ if not TQUriDrag.canDecode(e) :
+ e.ignore()
+ return
+ vp = self.contentsToViewport( e.pos() )
+ i = self.itemAt( vp )
+ if i :
+ self.setSelected( i, True )
+ e.accept()
+ if i != self.dropItem :
+ self.autoopen_timer.stop()
+ self.dropItem = i
+ self.autoopen_timer.start( self.autoopenTime )
+
+ if e.action() == TQDropEvent.Copy:
+ pass
+ elif e.action() == TQDropEvent.Move:
+ e.acceptAction()
+ elif e.action() == TQDropEvent.Link:
+ e.acceptAction()
+ else:
+ pass
+ else :
+ e.ignore()
+ self.autoopen_timer.stop()
+ self.dropItem = 0
+
+ def contentsDragLeaveEvent( self, TQDragLeaveEvent ) :
+ self.autoopen_timer.stop()
+ self.dropItem = 0
+
+ self.setCurrentItem( self.oldCurrent )
+ self.setSelected( self.oldCurrent, True )
+
+ def contentsDropEvent( self, e ):
+ self.autoopen_timer.stop()
+ if not TQUriDrag.canDecode(e) :
+ e.ignore()
+ return
+ item = self.itemAt( self.contentsToViewport(e.pos()) )
+ if item :
+ lst = TQStringList()
+ TQUriDrag.decodeLocalFiles( e, lst )
+ if e.action() == TQDropEvent.Copy:
+ s = TQString("Copy")
+ elif e.action() == TQDropEvent.Move:
+ s = TQString("Move")
+ e.acceptAction()
+ elif e.action() == TQDropEvent.Link:
+ s = TQString("Link")
+ e.acceptAction()
+ else:
+ s = TQString("Unknown")
+
+ s += "\n\n"
+ e.accept()
+
+ for filename in lst:
+ s += filename
+ s += "\n"
+
+ s += "\nTo\n\n "
+ s += self.fullPath(item)
+ TQMessageBox.information( self, "Drop target", s, "Not implemented" )
+ else :
+ e.ignore()
+
+ def fullPath( self, item ):
+ fullpath = TQString( item.text(0) )
+ item = item.parent()
+ while item:
+ newpath = item.text(0)
+
+ if item.parent():
+ newpath += "/"
+
+ newpath += fullpath
+ fullpath = newpath
+ item = item.parent()
+
+ return fullpath
+
+ def contentsMousePressEvent( self, e ) :
+ TQListView.contentsMousePressEvent( self, e )
+ p = TQPoint( self.contentsToViewport( e.pos() ) )
+ i = self.itemAt( p )
+ if i :
+ # if the user clicked into the root decoration of the item, don't try to start a drag!
+ if self.rootIsDecorated(): isdecorated = 1
+ else : isdecorated = 0
+ if p.x() > self.header().sectionPos( self.header().mapToIndex( 0 )) + self.treeStepSize() * ( i.depth() + isdecorated + self.itemMargin() or
+ p.x() < self.header().sectionPos( self.header().mapToIndex( 0 ) ) ) :
+ self.presspos.setX(e.pos().x())
+ self.presspos.setY(e.pos().y())
+ self.mousePressed = True
+
+ def contentsMouseMoveEvent( self, e ):
+ offset = TQPoint( self.presspos.x() - e.pos().x(),
+ self.presspos.y() - e.pos().y() )
+ if self.mousePressed and (offset).manhattanLength() > TQApplication.startDragDistance() :
+ self.mousePressed = False
+ item = self.itemAt( self.contentsToViewport(self.presspos) )
+ if item :
+ source = self.fullPath(item)
+ if TQFile.exists(source) :
+ ud = TQUriDrag(self.viewport())
+ ud.setFileNames( TQStringList (source) )
+ if ud.drag() :
+ TQMessageBox.information( self, "Drag source",
+ TQString("Delete ")+source, "Not implemented" )
+
+ def contentsMouseReleaseEvent( self, TQMouseEvent ):
+ self.mousePressed = False
+
+ def setDir( self, s ):
+ it = TQListViewItem( self )
+ it.setOpen(False)
+ thisDir = TQDir( s )
+ it = TQListViewItem( self )
+ it.setOpen(False)
+ lst = TQStringList( TQStringList.split( "/", s ) )
+ listview2 = []
+ listview2.extend( lst )
+
+ item = self.firstChild()
+ for it2 in listview2 :
+ while item :
+ if item.text( 0 ) == it2 :
+ item.setOpen( True )
+ break
+ item = item.itemBelow()
+ if item:
+ self.setCurrentItem( item )
+
+def main( args ):
+ a = TQApplication( args )
+
+ mw = DirectoryView()
+ mw.addColumn( "Name" )
+ mw.addColumn( "Type" )
+ mw.setTreeStepSize( 20 )
+
+ roots = TQDir.drives()
+ if roots :
+ for it in roots:
+ fi = it
+ root = Directory( mw, fi.filePath() )
+ if roots.count(it) <= 1 :
+ root.setOpen( True ) # be interesting
+
+ mw.resize( 400, 400 )
+ mw.setCaption( "TQt Example - Directory Browser" )
+ mw.setAllColumnsShowFocus( True )
+ a.setMainWidget( mw )
+ mw.show()
+
+ a.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/dragdrop.py b/examples/dragdrop.py
new file mode 100755
index 0000000..a715170
--- /dev/null
+++ b/examples/dragdrop.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+
+# Ported to PyTQt by Issac Trotts on Jan 1, 2002
+
+import sys
+from python_tqt.qt import *
+
+import dropsite, secret
+
+
+def addStuff( parent, yn_image, yn_secret = 0 ):
+ tll = TQVBoxLayout( parent, 10 )
+ d = dropsite.DropSite( parent, 'dropsite' )
+ d.setFrameStyle( TQFrame.Sunken + TQFrame.WinPanel )
+ tll.addWidget( d )
+ if yn_image:
+ stuff = TQPixmap()
+ if not stuff.load( "trolltech.bmp" ):
+ stuff = TQPixmap(20,20)
+ stuff.fill(TQt.green)
+ d.setPixmap( stuff )
+ else:
+ d.setText("Drag and Drop")
+ d.setFont(TQFont("Helvetica",18))
+ if secret:
+ s = secret.SecretSource( 42, parent )
+ tll.addWidget( s )
+
+ format = TQLabel( "\n\n\n\nNone\n\n\n\n", parent )
+ tll.addWidget( format )
+ tll.activate()
+ parent.resize( parent.sizeHint() )
+
+ TQObject.connect( d, PYSIGNAL('message(TQString &)'),
+ format, SLOT('setText(TQString &)') )
+
+
+app = TQApplication( sys.argv )
+
+mw = TQWidget()
+addStuff( mw, 1 )
+mw.setCaption( "TQt Example - Drag and Drop" )
+mw.show()
+
+mw2 = TQWidget()
+addStuff( mw2, 0 )
+mw2.setCaption( "TQt Example - Drag and Drop" )
+mw2.show()
+
+mw3 = TQWidget()
+addStuff( mw3, 1, 1 )
+mw3.setCaption( "TQt Example - Drag and Drop" )
+mw3.show()
+
+TQObject.connect(tqApp,SIGNAL('lastWindowClosed()'),tqApp,SLOT('quit()'))
+
+app.exec_loop()
diff --git a/examples/drawlines.py b/examples/drawlines.py
new file mode 100755
index 0000000..c1553f2
--- /dev/null
+++ b/examples/drawlines.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+
+import sys, random
+from python_tqt.qt import *
+
+TRUE = 1
+FALSE = 0
+
+MAXPOINTS = 2000; # maximum number of points
+MAXCOLORS = 40;
+
+#
+# ConnectWidget - draws connected lines
+#
+
+class ConnectWidget(TQWidget):
+ def __init__(self):
+ TQWidget.__init__(self)
+ self.setEraseColor( TQt.white ) # white background
+ self.count = 0;
+ self.down = FALSE
+
+ self.points = []
+ self.colors = []
+
+ for i in range(MAXPOINTS): # init arrays
+ self.points.append(TQPoint())
+ for i in range(MAXCOLORS):
+ self.colors.append(TQColor( random.randint(0,255), random.randint(0,255), random.randint(0,255) ))
+
+#
+# Handles paint events for the connect widget.
+#
+ def paintEvent(self, pe):
+ paint = TQPainter( self )
+ for i in range(self.count-1): # connect all points
+ for j in range(i+1, self.count):
+ paint.setPen( self.colors[random.randint(0,MAXCOLORS-1)] ) # set random pen color
+ paint.drawLine( self.points[i], self.points[j] ) # draw line
+
+#
+# Handles mouse press events for the connect widget.
+#
+ def mousePressEvent(self, me):
+ self.down = TRUE
+ self.count = 0 # start recording points
+ self.erase() # erase widget contents
+
+#
+# Handles mouse release events for the connect widget.
+#
+ def mouseReleaseEvent(self, me ):
+ self.down = FALSE # done recording points
+ self.update() # draw the lines
+
+#
+# Handles mouse move events for the connect widget.
+#
+ def mouseMoveEvent(self, me):
+ if self.down and self.count < MAXPOINTS:
+ paint = TQPainter( self )
+ self.points[self.count] = TQPoint(me.pos()) # add point
+ paint.drawPoint( me.pos() ) # plot point
+ self.count = self.count+1
+
+#
+# Create and display a ConnectWidget.
+#
+a = TQApplication( sys.argv )
+connect = ConnectWidget()
+connect.setCaption( "PyTQt Example - Draw lines")
+a.setMainWidget( connect )
+connect.show()
+a.exec_loop()
diff --git a/examples/dropsite.py b/examples/dropsite.py
new file mode 100644
index 0000000..8581e0e
--- /dev/null
+++ b/examples/dropsite.py
@@ -0,0 +1,96 @@
+# This is part of the dragdrop example.
+
+
+from python_tqt.qt import *
+
+import secret
+
+
+class DropSite(TQLabel):
+ def __init__(self, parent=None, name=None):
+ TQLabel.__init__( self, parent, name )
+ self.setAcceptDrops(1)
+
+ # this is a normal event
+ def mousePressEvent( self, e ):
+ if ( self.pixmap() ) :
+ drobj = TQImageDrag( self.pixmap().convertToImage(), self )
+ pm = TQPixmap()
+ pm.convertFromImage(self.pixmap().convertToImage().smoothScale(
+ self.pixmap().width()/3,self.pixmap().height()/3))
+ drobj.setPixmap(pm,TQPoint(-5,-7))
+ else :
+ drobj = TQTextDrag( self.text(), self )
+ drobj.dragCopy()
+
+ def backgroundColorChange( self, qcolor ):
+ # Reduce flicker by using repaint() rather than update()
+ self.repaint()
+
+ def dragMoveEvent( self, e ):
+ # Check if you want the drag at e.pos()...
+ # Give the user some feedback...
+ pass
+
+ def dragEnterEvent( self, e ):
+ # Check if you want the drag...
+ if (secret.canDecode( e ) or
+ TQTextDrag.canDecode( e ) or
+ TQImageDrag.canDecode( e ) or
+ TQUriDrag.canDecode( e )):
+ e.accept()
+
+ # Give the user some feedback...
+ t = ''
+ i = 0
+ while e.format( i ):
+ if ( t != '' ):
+ t += "\n"
+ t += str(e.format( i ))
+ i += 1
+ self.emit(PYSIGNAL('message(TQString &)'), (TQString(t),))
+ self.setEraseColor(TQt.white)
+
+ def dragLeaveEvent( self, TQDragLeaveEvent ):
+ # Give the user some feedback...
+ self.emit(PYSIGNAL('message(TQString &)'), (TQString(''),))
+ self.setEraseColor(TQt.lightGray)
+
+ def dropEvent( self, e ):
+ self.setEraseColor(TQt.lightGray)
+ # Try to decode to the data you understand...
+ str = TQString()
+ if ( TQTextDrag.decode( e, str ) ) :
+ self.setText( str )
+ self.setMinimumSize( self.minimumSize().expandedTo(self.sizeHint()) )
+ return
+
+ pm = TQPixmap()
+ if ( TQImageDrag.decode( e, pm ) ) :
+ self.setPixmap( pm )
+ self.setMinimumSize(self.minimumSize().expandedTo(self.sizeHint()))
+ return
+
+ # TQStrList strings
+ #strings = TQStrList()
+ strings = []
+ if ( TQUriDrag.decode( e, strings ) ) :
+ m = TQString("Full URLs:\n")
+ for u in strings:
+ m = m + " " + u + '\n'
+ # TQStringList files
+ files = []
+ if ( TQUriDrag.decodeLocalFiles( e, files ) ) :
+ m += "Files:\n"
+ # for (TQStringList.Iterator i=files.begin() i!=files.end() ++i)
+ for i in files:
+ m = m + " " + i + '\n'
+ self.setText( m )
+ self.setMinimumSize(self.minimumSize().expandedTo(self.sizeHint()))
+ return
+
+ str = secret.decode( e )
+ if str:
+ self.setText( str )
+ self.setMinimumSize(self.minimumSize().expandedTo(self.sizeHint()))
+ return
diff --git a/examples/fileopen.xpm b/examples/fileopen.xpm
new file mode 100644
index 0000000..880417e
--- /dev/null
+++ b/examples/fileopen.xpm
@@ -0,0 +1,22 @@
+/* XPM */
+static const char *fileopen[] = {
+" 16 13 5 1",
+". c #040404",
+"# c #808304",
+"a c None",
+"b c #f3f704",
+"c c #f3f7f3",
+"aaaaaaaaa...aaaa",
+"aaaaaaaa.aaa.a.a",
+"aaaaaaaaaaaaa..a",
+"a...aaaaaaaa...a",
+".bcb.......aaaaa",
+".cbcbcbcbc.aaaaa",
+".bcbcbcbcb.aaaaa",
+".cbcb...........",
+".bcb.#########.a",
+".cb.#########.aa",
+".b.#########.aaa",
+"..#########.aaaa",
+"...........aaaaa"
+};
diff --git a/examples/fontdisplayer.py b/examples/fontdisplayer.py
new file mode 100755
index 0000000..1f616bf
--- /dev/null
+++ b/examples/fontdisplayer.py
@@ -0,0 +1,148 @@
+#!/usr/bin/env python
+
+"""**************************************************************************
+** $Id: fontdisplayer.py,v 1.2 2004/07/19 18:41:53 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+
+class FontRowTable( TQFrame ):
+ def __init__( self, parent=None, name=None ):
+ TQFrame.__init__( self, parent, name )
+
+ self.setBackgroundMode(self.PaletteBase)
+ self.setFrameStyle(self.Panel|self.Sunken)
+ self.setMargin(8)
+ self.setRow(0)
+ self.row = 0
+ self.tablefont = TQFont( TQApplication.font() )
+
+ def sizeHint( self ) :
+ width = 16*self.cellSize().width()+TQSize(2,2).width()*(self.margin()+self.frameWidth())
+ height = 16*self.cellSize().height()+TQSize(2,2).height()*(self.margin()+self.frameWidth())
+ return TQSize(width,height)
+
+ def cellSize( self ) :
+ fm = self.fontMetrics()
+ return TQSize( fm.maxWidth(), fm.lineSpacing() + 1 )
+
+ def paintEvent( self, e ):
+ TQFrame.paintEvent(self, e)
+ p = TQPainter(self)
+ p.setClipRegion(e.region())
+ r = TQRect(e.rect())
+ fm = self.fontMetrics()
+ ml = self.frameWidth() + self.margin() + 1 + max(0,-fm.minLeftBearing())
+ mt = self.frameWidth() + self.margin()
+ cell = TQSize(int((self.width()-15-ml)/16),int((self.height()-15-mt)/16))
+
+ if not cell.width() or not cell.height() :
+ return
+
+ mini = int(r.left() / cell.width())
+ maxi = int((r.right()+cell.width()-1) / cell.width())
+ minj = int(r.top() / cell.height())
+ maxj = int((r.bottom()+cell.height()-1) / cell.height())
+
+ h = fm.height()
+
+ body = TQColor(255,255,192);
+ negative = TQColor(255,192,192);
+ positive = TQColor(192,192,255);
+ rnegative = TQColor(255,128,128);
+ rpositive = TQColor(128,128,255);
+
+ for j in range(minj, maxj+1, 1) :
+ for i in range(mini, maxi+1, 1) :
+ if i < 16 and j < 16 :
+ x = i*cell.width()
+ y = j*cell.height()
+
+ ch = TQChar(j*16+i) #,self.row) # just accept one argument!!!
+
+ if fm.inFont(ch) :
+ w = fm.width(ch)
+ l = fm.leftBearing(ch)
+ r = fm.rightBearing(ch)
+
+ x += ml
+ y += mt+h
+
+ p.fillRect(x,y,w,-h,TQBrush(body))
+
+ if w :
+ if l :
+ if l < 0: sign = negative
+ else: sign = positive
+ if l > 0: lsign = 0
+ else: lsign = 1
+ p.fillRect(x+lsign, int(y-h/2), abs(l),int(-h/2), TQBrush(sign))
+ if r :
+ if r < 0: sign = rnegative
+ else: sign = rpositive
+ if r > 0: rsign = r
+ else: rsign = 0
+ p.fillRect(int(x+w-rsign),y+2, abs(r),int(-h/2), TQBrush(sign))
+ s = TQString( ch )
+ p.setPen(TQPen(TQt.black))
+ p.drawText(x,y,s)
+
+ def setRow( self, r ) :
+ self.row = r
+
+ fm = self.fontMetrics()
+ str = " minLB=%d minRB=%d maxW=%d" % (fm.minLeftBearing(), fm.minRightBearing(), fm.maxWidth())
+ self.emit( PYSIGNAL("fontInformation"), ( TQString(str), ) )
+ self.update()
+
+ def chooseFont( self ) :
+ ok = 0
+ oldfont = TQFont( self.tablefont )
+ self.tablefont, ok = TQFontDialog.getFont(oldfont, self)
+ if ok:
+ self.setFont(self.tablefont)
+ else:
+ self.tablefont = oldfont
+
+class FontDisplayer( TQMainWindow ) :
+ def __init__( self, parent=None, name=None ):
+ TQMainWindow.__init__( self, parent, name )
+ table = FontRowTable(self)
+ controls = TQToolBar(self)
+
+ TQLabel(self.tr("Row:"), controls)
+ self.row = TQSpinBox(0,255,1,controls)
+ controls.addSeparator()
+ fontbutton = TQPushButton(self.tr("Font..."), controls)
+ status = TQStatusBar(self)
+
+ self.connect( self.row, SIGNAL("valueChanged(int)"), table.setRow )
+ self.connect( fontbutton, SIGNAL("clicked()"), table.chooseFont )
+ self.connect( table, PYSIGNAL("fontInformation"),
+ status, SLOT("message(const TQString&)") )
+ table.setRow(0)
+ self.setCentralWidget(table)
+
+def main( args ):
+ # Use an interesting font
+ TQApplication.setFont(TQFont("unifont",16))
+ app = TQApplication(sys.argv)
+
+ m = FontDisplayer()
+ sh = TQSize( m.centralWidget().sizeHint() )
+ m.resize(sh.width(), sh.height() + 3 * m.statusBar().height())
+ app.setMainWidget(m);
+ m.setCaption("TQt Example - TQFD");
+ m.show()
+
+ app.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/fonts.py b/examples/fonts.py
new file mode 100755
index 0000000..145b815
--- /dev/null
+++ b/examples/fonts.py
@@ -0,0 +1,149 @@
+#!/usr/bin/env python
+
+"""**************************************************************************
+** $Id: fonts.py,v 1.1 2003/07/01 14:18:37 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+
+class Viewer( TQWidget ):
+ def __init__( self ):
+ TQWidget.__init__( self )
+
+ self.setFontSubstitutions()
+
+ greeting_heb = TQString.fromUtf8( b"\327\251\327\234\327\225\327\235" )
+ greeting_ru = TQString.fromUtf8( b"\320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\271\321\202\320\265" )
+ greeting_en = "Hello"
+
+ self.greetings = TQTextView( self, "textview" )
+
+ self.greetings.setText( greeting_en + "\n" +
+ greeting_ru + "\n" +
+ greeting_heb )
+
+ self.fontInfo = TQTextView( self, "fontinfo" )
+
+ self.setDefault()
+
+ self.defaultButton = TQPushButton( "Default", self, "pushbutton1" )
+ self.defaultButton.setFont( TQFont( "times" ) )
+ self.connect( self.defaultButton, SIGNAL("clicked()"), self.setDefault )
+
+ self.sansSerifButton = TQPushButton( "Sans Serif", self, "pushbutton2" )
+ self.sansSerifButton.setFont( TQFont( "Helvetica", 12 ) )
+ self.connect( self.sansSerifButton, SIGNAL("clicked()"), self.setSansSerif )
+
+ self.italicsButton = TQPushButton( "Italics", self, "pushbutton3" )
+ self.italicsButton.setFont( TQFont( "lucida", 12, TQFont.Bold, True ) )
+ self.connect( self.italicsButton, SIGNAL("clicked()"), self.setItalics )
+
+ self.layout()
+
+ def setDefault( self ):
+ font = TQFont( "Bavaria" )
+ font.setPointSize( 24 )
+ font.setWeight( TQFont.Bold )
+ font.setUnderline( True )
+
+ self.greetings.setFont( font )
+
+ self.showFontInfo( font )
+
+ def setSansSerif( self ):
+ font = TQFont( "Newyork", 18 )
+ font.setStyleHint( TQFont.SansSerif )
+
+ self.greetings.setFont( font )
+
+ self.showFontInfo( font )
+
+ def setItalics( self ):
+ font = TQFont( "Tokyo" )
+ font.setPointSize( 32 )
+ font.setWeight( TQFont.Bold )
+ font.setItalic( True )
+
+ self.greetings.setFont( font )
+
+ self.showFontInfo( font )
+
+ def showFontInfo( self, font ):
+ info = TQFontInfo( font )
+
+ messageText = "Font requested: \"" + str(font.family()) + "\" " \
+ + str(TQString.number( font.pointSize() )) + "pt<BR>" \
+ + "Font used: \"" + str(info.family()) + "\" " \
+ + str(TQString.number( info.pointSize() )) + "pt<P>"
+
+ if not self.substitutes.isEmpty() :
+ messageText += "The following substitutions exist for " + \
+ str(font.family()) + ":<UL>"
+ for i in self.substitutes :
+ messageText += "<LI>\"" + str(i) + "\""
+ messageText += "</UL>";
+ else :
+ messageText += "No substitutions exist for " + \
+ str(font.family()) + "."
+
+ self.fontInfo.setText( messageText )
+
+ def setFontSubstitutions( self ):
+ self.substitutes = TQStringList()
+ self.substitutes.append( "Times" )
+ self.substitutes.append( "Mincho" )
+ self.substitutes.append( "Arabic Newspaper" )
+ self.substitutes.append( "crox" )
+ #TQFont.insertSubstitutions( "Bavaria", self.substitutes )
+ TQFont.insertSubstitution( "Bavaria", "Times" )
+ TQFont.insertSubstitution( "Tokyo", "Lucida" )
+
+ # For those who prefer to use TQt Designer for creating GUIs
+ # the following function might not be of particular interest:
+ # all it does is creating the widget layout.
+ def layout( self ):
+ textViewContainer = TQHBoxLayout()
+ textViewContainer.addWidget( self.greetings )
+ textViewContainer.addWidget( self.fontInfo )
+
+ buttonContainer = TQHBoxLayout()
+ buttonContainer.addWidget( self.defaultButton )
+ buttonContainer.addWidget( self.sansSerifButton )
+ buttonContainer.addWidget( self.italicsButton )
+
+ maxButtonHeight = self.defaultButton.height()
+
+ if self.sansSerifButton.height() > maxButtonHeight :
+ maxButtonHeight = self.sansSerifButton.height()
+ if self.italicsButton.height() > maxButtonHeight :
+ maxButtonHeight = self.italicsButton.height()
+
+ self.defaultButton.setFixedHeight( maxButtonHeight )
+ self.sansSerifButton.setFixedHeight( maxButtonHeight )
+ self.italicsButton.setFixedHeight( maxButtonHeight )
+
+ container = TQVBoxLayout( self )
+ container.addLayout( textViewContainer )
+ container.addLayout( buttonContainer )
+
+ self.resize( 700, 250 )
+
+def main( args ):
+ app = TQApplication(sys.argv) # application object
+
+ textViewer = Viewer()
+ textViewer.setCaption( "TQt Example - Simple TQFont Demo" )
+ app.setMainWidget( textViewer )
+ textViewer.show()
+
+ app.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/gears.py b/examples/gears.py
new file mode 100755
index 0000000..e98df55
--- /dev/null
+++ b/examples/gears.py
@@ -0,0 +1,235 @@
+#!/usr/bin/env python
+
+
+import sys
+import math
+from python_tqt.qt import *
+from python_tqt.qtgl import *
+from OpenGL.GL import *
+
+def gear(inner_radius,outer_radius,width,teeth,tooth_depth):
+ r0 = inner_radius
+ r1 = outer_radius - tooth_depth/2.0
+ r2 = outer_radius + tooth_depth/2.0
+
+ da = 2.0*math.pi/teeth/4.0
+
+ glShadeModel(GL_FLAT)
+
+ glNormal3f(0.0,0.0,1.0)
+
+ # draw front face
+
+ glBegin(GL_QUAD_STRIP)
+
+ for i in range(teeth+1):
+ angle = i * 2.0*math.pi/teeth
+ glVertex3f(r0*math.cos(angle), r0*math.sin(angle), width*0.5 )
+ glVertex3f(r1*math.cos(angle), r1*math.sin(angle), width*0.5 )
+ glVertex3f(r0*math.cos(angle), r0*math.sin(angle), width*0.5 )
+ glVertex3f(r1*math.cos(angle+3*da), r1*math.sin(angle+3*da), width*0.5 )
+
+ glEnd()
+
+ # draw front sides of teeth
+
+ da = 2.0*math.pi/teeth/4.0
+
+ glBegin(GL_QUADS)
+
+ for i in range(teeth):
+ angle = i*2.0*math.pi/teeth
+
+ glVertex3f( r1*math.cos(angle), r1*math.sin(angle), width*0.5 )
+ glVertex3f( r2*math.cos(angle+da), r2*math.sin(angle+da), width*0.5 )
+ glVertex3f( r2*math.cos(angle+2*da), r2*math.sin(angle+2*da), width*0.5 )
+ glVertex3f( r1*math.cos(angle+3*da), r1*math.sin(angle+3*da), width*0.5 )
+
+ glEnd()
+
+
+ glNormal3f( 0.0, 0.0, -1.0 )
+
+ # draw back face
+
+ glBegin( GL_QUAD_STRIP )
+
+ for i in range(teeth+1):
+ angle = i*2.0*math.pi/teeth
+
+ glVertex3f( r1*math.cos(angle), r1*math.sin(angle), -width*0.5 )
+ glVertex3f( r0*math.cos(angle), r0*math.sin(angle), -width*0.5 )
+ glVertex3f( r1*math.cos(angle+3*da), r1*math.sin(angle+3*da), -width*0.5 )
+ glVertex3f( r0*math.cos(angle), r0*math.sin(angle), -width*0.5 )
+
+ glEnd()
+
+ # draw back sides of teeth
+
+ da = 2.0*math.pi/teeth/4.0
+
+ glBegin( GL_QUADS )
+
+ for i in range(teeth):
+ angle = i*2.0*math.pi/teeth
+
+ glVertex3f( r1*math.cos(angle+3*da), r1*math.sin(angle+3*da), -width*0.5 )
+ glVertex3f( r2*math.cos(angle+2*da), r2*math.sin(angle+2*da), -width*0.5 )
+ glVertex3f( r2*math.cos(angle+da), r2*math.sin(angle+da), -width*0.5 )
+ glVertex3f( r1*math.cos(angle), r1*math.sin(angle), -width*0.5 )
+
+ glEnd()
+
+ # draw outward faces of teeth
+
+ glBegin( GL_QUAD_STRIP )
+
+ for i in range(teeth):
+ angle = i*2.0*math.pi/teeth
+
+ glVertex3f( r1*math.cos(angle), r1*math.sin(angle), width*0.5 )
+ glVertex3f( r1*math.cos(angle), r1*math.sin(angle), -width*0.5 )
+
+ u = r2*math.cos(angle+da) - r1*math.cos(angle)
+ v = r2*math.sin(angle+da) - r1*math.sin(angle)
+
+ len = math.sqrt( u*u + v*v )
+ u /= len
+ v /= len
+ glNormal3f( v, -u, 0.0 )
+ glVertex3f( r2*math.cos(angle+da), r2*math.sin(angle+da), width*0.5 )
+ glVertex3f( r2*math.cos(angle+da), r2*math.sin(angle+da), -width*0.5 )
+ glNormal3f( math.cos(angle), math.sin(angle), 0.0 )
+ glVertex3f( r2*math.cos(angle+2*da), r2*math.sin(angle+2*da), width*0.5 )
+ glVertex3f( r2*math.cos(angle+2*da), r2*math.sin(angle+2*da), -width*0.5 )
+ u = r1*math.cos(angle+3*da) - r2*math.cos(angle+2*da)
+ v = r1*math.sin(angle+3*da) - r2*math.sin(angle+2*da)
+ glNormal3f( v, -u, 0.0 )
+ glVertex3f( r1*math.cos(angle+3*da), r1*math.sin(angle+3*da), width*0.5 )
+ glVertex3f( r1*math.cos(angle+3*da), r1*math.sin(angle+3*da), -width*0.5 )
+ glNormal3f( math.cos(angle), math.sin(angle), 0.0 )
+
+ glVertex3f( r1*math.cos(0.0), r1*math.sin(0.0), width*0.5 )
+ glVertex3f( r1*math.cos(0.0), r1*math.sin(0.0), -width*0.5 )
+
+ glEnd()
+
+ glShadeModel (GL_SMOOTH)
+
+ # draw inside radius cylinder
+
+ glBegin( GL_QUAD_STRIP )
+
+ for i in range(teeth+1):
+ angle = i * 2.0*math.pi / teeth
+ glNormal3f( -math.cos(angle), -math.sin(angle), 0.0 )
+ glVertex3f( r0*math.cos(angle), r0*math.sin(angle), -width*0.5 )
+ glVertex3f( r0*math.cos(angle), r0*math.sin(angle), width*0.5 )
+
+ glEnd()
+
+##############################################################################
+class GearWidget(TQGLWidget):
+ def __init__(self,parent=None,name=None):
+ TQGLWidget.__init__(self,parent,name)
+
+ self.angle=0.0
+ self.view_rotx=0.0
+ self.view_roty=0.0
+ self.view_rotz=0.0
+
+ self.startTimer(10)
+
+ def timerEvent(self,event):
+ self.updateGL()
+
+ def paintGL(self):
+ self.angle = self.angle + 2.0
+ self.view_rotx = self.view_rotx + 1.0
+ self.view_roty = self.view_roty + 3.0
+ self.view_rotz = self.view_rotz + 2.0
+
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
+
+ glPushMatrix()
+ glRotatef( self.view_rotx, 1.0, 0.0, 0.0 )
+ glRotatef( self.view_roty, 0.0, 1.0, 0.0 )
+ glRotatef( self.view_rotz, 0.0, 0.0, 1.0 )
+
+ glPushMatrix()
+ glTranslatef( -3.0, -2.0, 0.0 )
+ glRotatef( self.angle, 0.0, 0.0, 1.0 )
+ glCallList(self.gear1)
+ glPopMatrix()
+
+ glPushMatrix()
+ glTranslatef( 3.1, -2.0, 0.0 )
+ glRotatef( -2.0*self.angle-9.0, 0.0, 0.0, 1.0 )
+ glCallList(self.gear2)
+ glPopMatrix()
+
+ glPushMatrix()
+ glTranslatef( -3.1, 2.2, -1.8 )
+ glRotatef( 90.0, 1.0, 0.0, 0.0 )
+ glRotatef( 2.0*self.angle-2.0, 0.0, 0.0, 1.0 )
+ glCallList(self.gear3)
+ glPopMatrix()
+
+ glPopMatrix()
+
+ def resizeGL(self,width,height):
+ w = width / float(height)
+ h = 1.0
+
+ glViewport( 0, 0, width, height )
+ glMatrixMode(GL_PROJECTION)
+ glLoadIdentity()
+ glFrustum( -w, w, -h, h, 5.0, 60.0 )
+ glMatrixMode(GL_MODELVIEW)
+ glLoadIdentity()
+ glTranslatef( 0.0, 0.0, -40.0 )
+
+ def initializeGL(self):
+ pos=(5.0, 5.0, 10.0, 1.0 )
+ ared=(0.8, 0.1, 0.0, 1.0 )
+ agreen=(0.0, 0.8, 0.2, 1.0 )
+ ablue=(0.2, 0.2, 1.0, 1.0 )
+
+ glLightfv(GL_LIGHT0,GL_POSITION,pos)
+ glEnable(GL_CULL_FACE)
+ glEnable(GL_LIGHTING)
+ glEnable(GL_LIGHT0)
+ glEnable(GL_DEPTH_TEST)
+
+ self.gear1=glGenLists(1)
+ glNewList(self.gear1,GL_COMPILE)
+ glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,ared)
+ gear(1.0,4.0,1.0,20,0.7)
+ glEndList()
+
+ self.gear2=glGenLists(1)
+ glNewList(self.gear2,GL_COMPILE)
+ glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,agreen)
+ gear(0.5,2.0,2.0,10,0.7)
+ glEndList()
+
+ self.gear3=glGenLists(1)
+ glNewList(self.gear3,GL_COMPILE)
+ glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,ablue)
+ gear(1.3,2.0,0.5,10,0.7)
+ glEndList()
+
+ glEnable(GL_NORMALIZE)
+
+##############################################################################
+if __name__=='__main__':
+ TQApplication.setColorSpec(TQApplication.CustomColor)
+ app=TQApplication(sys.argv)
+
+ if not TQGLFormat.hasOpenGL():
+ raise Exception('No TQt OpenGL support.')
+
+ widget=GearWidget()
+ app.setMainWidget(widget)
+ widget.show()
+ app.exec_loop()
diff --git a/examples/i18n/i18n.pro b/examples/i18n/i18n.pro
new file mode 100644
index 0000000..fc55895
--- /dev/null
+++ b/examples/i18n/i18n.pro
@@ -0,0 +1,15 @@
+SOURCES = mywidget.py \
+ i18n.py
+
+TRANSLATIONS = mywidget_cs.ts \
+ mywidget_de.ts \
+ mywidget_el.ts \
+ mywidget_en.ts \
+ mywidget_eo.ts \
+ mywidget_fr.ts \
+ mywidget_it.ts \
+ mywidget_jp.ts \
+ mywidget_ko.ts \
+ mywidget_no.ts \
+ mywidget_ru.ts \
+ mywidget_zh.ts
diff --git a/examples/i18n/i18n.py b/examples/i18n/i18n.py
new file mode 100755
index 0000000..b4dc42a
--- /dev/null
+++ b/examples/i18n/i18n.py
@@ -0,0 +1,147 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2002 Detlev Offenbach <detlev@die-offenbachs.de>
+
+from whrandom import randint
+import sys
+
+from python_tqt.qt import *
+
+from mywidget import MyWidget
+
+class TQVDialog(TQDialog):
+ def __init__(self, parent=None, name=None, modal=0, flags=0):
+ TQDialog.__init__(self, parent, name, modal, flags)
+
+ self.vb = TQVBoxLayout(self, 8)
+ self.vb.setAutoAdd(1)
+
+ self.hb = None
+ self.map = {}
+ #self.sm = TQSignalMapper(self)
+ self.connect(self, PYSIGNAL('mapped(int)'), self.done)
+
+ def addButtons(self, cancel=None, ok=None, mid1=None, mid2=None, mid3=None):
+ if ok is None:
+ self.addButton(self.tr("OK"),1)
+ else:
+ self.addButton(ok,1)
+
+ if mid1 is not None:
+ self.addButton(mid1,2)
+
+ if mid2 is not None:
+ self.addButton(mid2,3)
+
+ if mid3 is not None:
+ self.addButton(mid3,4)
+
+ if cancel is None:
+ self.addButton(self.tr('Cancel'),0)
+ else:
+ self.addButton(cancel,0)
+
+ def addButton(self, text, result):
+ if self.hb is None:
+ self.hb = TQHBox(self)
+ c = TQPushButton(text, self.hb)
+ self.setMapping(c, result)
+ self.connect(c, SIGNAL('clicked()'), self.mapit)
+
+ def setMapping(self, c, result):
+ self.map[c] = result
+
+ def mapit(self):
+ qo = self.sender()
+ self.emit(PYSIGNAL('mapped(int)'), (self.map[qo],))
+
+translator = None
+wlist = [] # keep reference to widgets
+
+def showLang(lang):
+ global translator
+
+ tqApp.setPalette(TQPalette(TQColor(220-randint(0,64),220-randint(0,64),220-randint(0,64))))
+
+ language = "mywidget_"+lang+".qm"
+ fi = TQFileInfo(language)
+
+ if not fi.exists():
+ TQMessageBox.warning(None, "File error",
+ "Cannot find translation for language: "+lang+\
+ "\n(try eg. 'de' or 'en')")
+ return None
+
+ if translator is not None:
+ tqApp.removeTranslator(translator)
+ translator = None
+
+ translator = TQTranslator(None)
+ translator.load(language,".")
+ tqApp.installTranslator(translator)
+ m = MyWidget()
+ m.setCaption("PyTQt Example - i18n - " + str(m.caption()))
+ wlist.append(m)
+ return m
+
+def main(argv):
+ app = TQApplication(argv)
+
+ qm = ["cs", "de", "el", "en", "eo", "fr", "it", "jp", "ko", "no", "ru", "zh"]
+
+ lang = None
+ if len(argv) == 2:
+ lang = argv[1]
+
+ if (len(argv) != 2) or (lang == "all"):
+ dlg = TQVDialog(None, None, 1)
+ qmb = []
+ r = 0
+ if lang == "all":
+ r=2
+ else:
+ bg = TQButtonGroup(4, TQt.Vertical, "Choose Locales", dlg)
+ loc = TQTextCodec.locale()
+ for i in range(0,len(qm)):
+ qmb.append(TQCheckBox(qm[i], bg))
+ qmb[i].setChecked(str(loc) == qm[i])
+ dlg.addButtons("Cancel","OK","All")
+ r = dlg.exec_loop()
+
+ if r:
+ tight = tqApp.desktop().screen().width < 1024
+ x = 5
+ y = 25
+ for i in range(0,len(qm)):
+ if (r == 2) or (qmb[i].isChecked()):
+ w = showLang(qm[i])
+
+ if w == None:
+ sys.exit(0)
+
+ app.connect(app, SIGNAL('lastWindowClosed()'), tqApp, SLOT('quit()'))
+ w.setGeometry(x,y,197,356)
+ w.show()
+ if tight:
+ x += 8
+ y += 8
+ else:
+ x += 205
+ if x > 1000:
+ x = 5
+ y += 384
+
+ else:
+ sys.exit(0)
+
+ else:
+ lang = argv[1]
+ m = showLang(lang)
+ app.setMainWidget(m)
+ m.setCaption("PyTQt Example - i18n")
+ m.show()
+
+ return app.exec_loop()
+
+if __name__ == "__main__":
+ main(sys.argv)
diff --git a/examples/i18n/mywidget.py b/examples/i18n/mywidget.py
new file mode 100644
index 0000000..8013c1c
--- /dev/null
+++ b/examples/i18n/mywidget.py
@@ -0,0 +1,47 @@
+# Copyright (c) 2002 Detlev Offenbach <detlev@die-offenbachs.de>
+
+from python_tqt.qt import *
+
+class MyWidget(TQMainWindow):
+
+ def __init__(self, parent=None, name=None):
+ TQMainWindow.__init__(self, parent, name)
+
+ self.central = TQVBox(self)
+ self.central.setMargin(5)
+ self.central.setSpacing(5)
+ self.setCentralWidget(self.central)
+
+ self.setCaption(self.trUtf8("""Internationalization Example"""))
+
+ self.file = TQPopupMenu(self)
+ self.file.insertItem(self.trUtf8("E&xit"), tqApp, SLOT("quit()"),
+ TQKeySequence(self.trUtf8("Ctrl+Q","File|Quit")))
+ self.menuBar().insertItem(self.trUtf8("&File"), self.file)
+
+ self.statusBar().message(self.trUtf8('''Language: English'''))
+
+ self.label = TQLabel(self.trUtf8("The Main Window"), self.central)
+
+ self.gbox = TQButtonGroup(1, TQGroupBox.Horizontal,
+ self.trUtf8("View"), self.central)
+ rb = TQRadioButton(tqApp.translate('MyWidget','Perspective'), self.gbox)
+ rb = TQRadioButton(tqApp.translate('MyWidget','Isometric'), self.gbox)
+ rb = TQRadioButton(tqApp.translate('MyWidget','Oblique'), self.gbox)
+
+ self.initChoices(self.central)
+
+ choices = [
+ QT_TRANSLATE_NOOP("MyWidget", "First"),
+ QT_TRANSLATE_NOOP("MyWidget", "Second"),
+ QT_TRANSLATE_NOOP("MyWidget", "Third")
+ ]
+
+ def initChoices(self, parent):
+ self.lb = TQListBox(parent)
+ for ch in self.choices:
+ self.lb.insertItem(self.trUtf8(ch))
+
+ def closeEvent(self, e):
+ TQWidget.closeEvent(self, e)
+ self.emit(PYSIGNAL('closed'), ())
diff --git a/examples/i18n/mywidget_cs.qm b/examples/i18n/mywidget_cs.qm
new file mode 100644
index 0000000..f95090d
--- /dev/null
+++ b/examples/i18n/mywidget_cs.qm
Binary files differ
diff --git a/examples/i18n/mywidget_cs.ts b/examples/i18n/mywidget_cs.ts
new file mode 100644
index 0000000..2b82f04
--- /dev/null
+++ b/examples/i18n/mywidget_cs.ts
@@ -0,0 +1,75 @@
+<!DOCTYPE TS><TS>
+<context encoding="UTF-8">
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">Pohled</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>&amp;File</source>
+ <translation type="unfinished">&amp;Soubor</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>E&amp;xit</source>
+ <translation type="unfinished">&amp;Konec</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">První</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">Třetí</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">Jayzk: Český</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">Hlavní okno</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Ctrl+Q</source>
+ <translation type="unfinished">Ctrl+Q</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">Nakloněný</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">Druhý</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">Isometrický</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">Perspektivní</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">Ukázka lokalizace</translation>
+ </message>
+</context>
+<context encoding="UTF-8">
+ <name>TQAccel</name>
+ <message encoding="UTF-8">
+ <source>Ctrl</source>
+ <translation type="obsolete">Ctrl</translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_de.qm b/examples/i18n/mywidget_de.qm
new file mode 100644
index 0000000..6433855
--- /dev/null
+++ b/examples/i18n/mywidget_de.qm
Binary files differ
diff --git a/examples/i18n/mywidget_de.ts b/examples/i18n/mywidget_de.ts
new file mode 100644
index 0000000..0a60c2b
--- /dev/null
+++ b/examples/i18n/mywidget_de.ts
@@ -0,0 +1,69 @@
+<!DOCTYPE TS><TS>
+<context>
+ <name>MyWidget</name>
+ <message>
+ <source>First</source>
+ <translation>Erstens</translation>
+ </message>
+ <message>
+ <source>Second</source>
+ <translation>Zweitens</translation>
+ </message>
+ <message>
+ <source>Third</source>
+ <translation>Drittens</translation>
+ </message>
+ <message>
+ <source>Internationalization Example</source>
+ <translation>Internationalisierungsbeispiel</translation>
+ </message>
+ <message>
+ <source>E&amp;xit</source>
+ <translation>Be&amp;enden</translation>
+ </message>
+ <message>
+ <source>&amp;File</source>
+ <translation>&amp;Datei</translation>
+ </message>
+ <message>
+ <source>Language: English</source>
+ <translation>Sprache: Deutsch</translation>
+ </message>
+ <message>
+ <source>The Main Window</source>
+ <translation>Das Hauptfenster</translation>
+ </message>
+ <message>
+ <source>View</source>
+ <translation>Ansicht</translation>
+ </message>
+ <message>
+ <source>Perspective</source>
+ <translation>Perspektivisch</translation>
+ </message>
+ <message>
+ <source>Isometric</source>
+ <translation>Isometrisch</translation>
+ </message>
+ <message>
+ <source>Oblique</source>
+ <translation>Schief</translation>
+ </message>
+ <message>
+ <source>Ctrl+Q</source>
+ <comment>File|Quit</comment>
+ <translation>Strg+Q</translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation>OK</translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation>Abbruch</translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_el.qm b/examples/i18n/mywidget_el.qm
new file mode 100644
index 0000000..15d7689
--- /dev/null
+++ b/examples/i18n/mywidget_el.qm
Binary files differ
diff --git a/examples/i18n/mywidget_el.ts b/examples/i18n/mywidget_el.ts
new file mode 100644
index 0000000..0d7a5dc
--- /dev/null
+++ b/examples/i18n/mywidget_el.ts
@@ -0,0 +1,68 @@
+<!DOCTYPE TS><TS>
+<context encoding="UTF-8">
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>&amp;File</source>
+ <translation type="unfinished">&amp;ΑÏχείο</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Ctrl+Q</source>
+ <translation type="unfinished">Ctrl+Q</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>E&amp;xit</source>
+ <translation type="unfinished">Έ&amp;ξοδος</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">ΠÏώτο</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">ΠαÏάδειγμα διεθνοποίησης</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">ΙσομετÏική</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">Γλώσσα: Ελληνικά</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">Πλάγια</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">ΠÏοοπτική</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">ΔεÏτεÏο</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">ΚÏÏιο παÏάθυÏο</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">ΤÏίτο</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">Όψη</translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_en.qm b/examples/i18n/mywidget_en.qm
new file mode 100644
index 0000000..6bd22c4
--- /dev/null
+++ b/examples/i18n/mywidget_en.qm
Binary files differ
diff --git a/examples/i18n/mywidget_en.ts b/examples/i18n/mywidget_en.ts
new file mode 100644
index 0000000..30a6e66
--- /dev/null
+++ b/examples/i18n/mywidget_en.ts
@@ -0,0 +1,69 @@
+<!DOCTYPE TS><TS>
+<context>
+ <name>MyWidget</name>
+ <message>
+ <source>First</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Second</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Third</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Internationalization Example</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>E&amp;xit</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&amp;File</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Language: English</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>The Main Window</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>View</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Perspective</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Isometric</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Oblique</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Ctrl+Q</source>
+ <comment>File|Quit</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_eo.qm b/examples/i18n/mywidget_eo.qm
new file mode 100644
index 0000000..372cf79
--- /dev/null
+++ b/examples/i18n/mywidget_eo.qm
Binary files differ
diff --git a/examples/i18n/mywidget_eo.ts b/examples/i18n/mywidget_eo.ts
new file mode 100644
index 0000000..f4eaef4
--- /dev/null
+++ b/examples/i18n/mywidget_eo.ts
@@ -0,0 +1,72 @@
+<!DOCTYPE TS><TS>
+<context encoding="UTF-8">
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>&amp;File</source>
+ <translation type="unfinished">&amp;Dosiero</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Ctrl+Q</source>
+ <translation type="unfinished">Ctrl+F</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>E&amp;xit...</source>
+ <translation type="obsolete">&amp;Fini...</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">Unue</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">Ekzemplo pri internaciigo</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">Isometria</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">Lingvo: Esperanto (ĈĜĤĴŜŬĉÄĥĵÅÅ­)</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">Oblikva</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">Perspektiva</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">Due</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">La Ĉeffenestro</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">Trie</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">Aspekto</translation>
+ </message>
+ <message>
+ <source>E&amp;xit</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_fr.qm b/examples/i18n/mywidget_fr.qm
new file mode 100644
index 0000000..12a8464
--- /dev/null
+++ b/examples/i18n/mywidget_fr.qm
Binary files differ
diff --git a/examples/i18n/mywidget_fr.ts b/examples/i18n/mywidget_fr.ts
new file mode 100644
index 0000000..3fa0191
--- /dev/null
+++ b/examples/i18n/mywidget_fr.ts
@@ -0,0 +1,68 @@
+<!DOCTYPE TS><TS>
+<context encoding="UTF-8">
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">Vue</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>&amp;File</source>
+ <translation type="unfinished">&amp;Fichier</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>E&amp;xit</source>
+ <translation type="unfinished">&amp;Quitter</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">Premier</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">Troisième</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">Langage : Français</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">La fenêtre principale</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Ctrl+Q</source>
+ <translation type="unfinished">Ctrl+Q</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">Oblique</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">Second</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">Isométrique</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">Perspective</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">Exemple d&apos;internationalisation</translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_it.qm b/examples/i18n/mywidget_it.qm
new file mode 100644
index 0000000..075bee2
--- /dev/null
+++ b/examples/i18n/mywidget_it.qm
Binary files differ
diff --git a/examples/i18n/mywidget_it.ts b/examples/i18n/mywidget_it.ts
new file mode 100644
index 0000000..4fa708c
--- /dev/null
+++ b/examples/i18n/mywidget_it.ts
@@ -0,0 +1,72 @@
+<!DOCTYPE TS><TS>
+<context>
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>E&amp;xit...</source>
+ <translation type="obsolete">&amp;Esci...</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">Primo</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">Esempio di localizzazione</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">Isometrica</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">Lingua: Italiano</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">Obliqua</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">Prospettica</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">Secondo</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">La Finestra Principale</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">Terzo</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">Vista</translation>
+ </message>
+ <message>
+ <source>E&amp;xit</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Ctrl+Q</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&amp;File</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_jp.qm b/examples/i18n/mywidget_jp.qm
new file mode 100644
index 0000000..8942dd7
--- /dev/null
+++ b/examples/i18n/mywidget_jp.qm
Binary files differ
diff --git a/examples/i18n/mywidget_jp.ts b/examples/i18n/mywidget_jp.ts
new file mode 100644
index 0000000..029dd0e
--- /dev/null
+++ b/examples/i18n/mywidget_jp.ts
@@ -0,0 +1,68 @@
+<!DOCTYPE TS><TS>
+<context encoding="UTF-8">
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>&amp;File</source>
+ <translation type="unfinished">ファイル(&amp;F)</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Ctrl+Q</source>
+ <translation type="unfinished">Ctrl+Q</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>E&amp;xit</source>
+ <translation type="unfinished">終了(&amp;X)</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">第一行</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">国際化(i18n)ã®ä¾‹</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">等角投影法</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">言語: 日本語</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">æ–œã‚投影法</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">é è¿‘法</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">第二行</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">メインウィンドウ</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">第三行</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">表示方å¼</translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_ko.qm b/examples/i18n/mywidget_ko.qm
new file mode 100644
index 0000000..dccc2ba
--- /dev/null
+++ b/examples/i18n/mywidget_ko.qm
Binary files differ
diff --git a/examples/i18n/mywidget_ko.ts b/examples/i18n/mywidget_ko.ts
new file mode 100644
index 0000000..632f8a7
--- /dev/null
+++ b/examples/i18n/mywidget_ko.ts
@@ -0,0 +1,68 @@
+<!DOCTYPE TS><TS>
+<context encoding="UTF-8">
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>&amp;File</source>
+ <translation type="unfinished">파ì¼&amp;F</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Ctrl+Q</source>
+ <translation type="unfinished">Ctrl+E</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>E&amp;xit</source>
+ <translation type="unfinished">종료&amp;X</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">첫번째</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">국제화 예제</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">Isometric</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">언어 : 한국어</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">Oblique</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">Perspective</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">ë‘번째</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">ë©”ì¸ ìœˆë„ìš°</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">세번째</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">보기</translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_no.qm b/examples/i18n/mywidget_no.qm
new file mode 100644
index 0000000..2adc136
--- /dev/null
+++ b/examples/i18n/mywidget_no.qm
Binary files differ
diff --git a/examples/i18n/mywidget_no.ts b/examples/i18n/mywidget_no.ts
new file mode 100644
index 0000000..b91293c
--- /dev/null
+++ b/examples/i18n/mywidget_no.ts
@@ -0,0 +1,68 @@
+<!DOCTYPE TS><TS>
+<context encoding="UTF-8">
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">Visning</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>&amp;File</source>
+ <translation type="unfinished">&amp;Fil</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>E&amp;xit</source>
+ <translation type="unfinished">&amp;Slutt</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">Første</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">Tredje</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">Språk: Norsk</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">Hovedvinduet</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Ctrl+Q</source>
+ <translation type="unfinished">Ctrl+S</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">Skjev</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">Andre</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">Isometrisk</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">Perspektiv</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">Internasjonaliseringseksempel</translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_ru.qm b/examples/i18n/mywidget_ru.qm
new file mode 100644
index 0000000..ebc512e
--- /dev/null
+++ b/examples/i18n/mywidget_ru.qm
Binary files differ
diff --git a/examples/i18n/mywidget_ru.ts b/examples/i18n/mywidget_ru.ts
new file mode 100644
index 0000000..d279ed1
--- /dev/null
+++ b/examples/i18n/mywidget_ru.ts
@@ -0,0 +1,68 @@
+<!DOCTYPE TS><TS>
+<context encoding="UTF-8">
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">Вид</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>&amp;File</source>
+ <translation type="unfinished">Файл</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>E&amp;xit</source>
+ <translation type="unfinished">Выход</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">Первый</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">Третий</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">Язык: РуÑÑкий</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">Главное окно</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">КурÑив</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">Второй</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">ИзометричеÑкий</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">ПерÑпектива</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">Пример интернациноализации</translation>
+ </message>
+ <message>
+ <source>Ctrl+Q</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/i18n/mywidget_zh.qm b/examples/i18n/mywidget_zh.qm
new file mode 100644
index 0000000..a890c09
--- /dev/null
+++ b/examples/i18n/mywidget_zh.qm
Binary files differ
diff --git a/examples/i18n/mywidget_zh.ts b/examples/i18n/mywidget_zh.ts
new file mode 100644
index 0000000..0dcb2df
--- /dev/null
+++ b/examples/i18n/mywidget_zh.ts
@@ -0,0 +1,68 @@
+<!DOCTYPE TS><TS>
+<context encoding="UTF-8">
+ <name>MyWidget</name>
+ <message encoding="UTF-8">
+ <source>View</source>
+ <translation type="unfinished">视图</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>&amp;File</source>
+ <translation type="unfinished">文件[&amp;F]</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>E&amp;xit</source>
+ <translation type="unfinished">退出[&amp;x]</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>First</source>
+ <translation type="unfinished">第一个</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Third</source>
+ <translation type="unfinished">第三个</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Language: English</source>
+ <translation type="unfinished">语言: 简体中文</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>The Main Window</source>
+ <translation type="unfinished">主窗å£</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Ctrl+Q</source>
+ <translation type="unfinished">Ctrl+Q</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Oblique</source>
+ <translation type="unfinished">斜投影</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Second</source>
+ <translation type="unfinished">第二个</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Isometric</source>
+ <translation type="unfinished">等角投影</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Perspective</source>
+ <translation type="unfinished">é€è§†æŠ•å½±</translation>
+ </message>
+ <message encoding="UTF-8">
+ <source>Internationalization Example</source>
+ <translation type="unfinished">国际化范例</translation>
+ </message>
+</context>
+<context>
+ <name>TQVDialog</name>
+ <message>
+ <source>OK</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Cancel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/lineedits.py b/examples/lineedits.py
new file mode 100755
index 0000000..0093f40
--- /dev/null
+++ b/examples/lineedits.py
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: lineedits.py,v 1.1 2002/06/19 07:56:07 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+
+TRUE = 1
+FALSE = 0
+
+class LineEdits(TQGroupBox):
+ def __init__(self, parent = None, name = None):
+ TQGroupBox.__init__(self, 0, TQt.Horizontal, "Line Edits", parent, name)
+
+ self.setMargin(10)
+
+ box = TQVBoxLayout(self.layout())
+
+ row1 = TQHBoxLayout(box)
+ row1.setMargin(5)
+
+ label = TQLabel("Echo Mode: ", self)
+ row1.addWidget(label)
+
+ combo1 = TQComboBox(FALSE, self)
+ row1.addWidget(combo1)
+ combo1.insertItem("Normal", -1)
+ combo1.insertItem("Password", -1)
+ combo1.insertItem("No Echo", -1)
+
+ self.connect(combo1, SIGNAL("activated(int)"), self.slotEchoChanged)
+ self.lined1 = TQLineEdit(self)
+ box.addWidget(self.lined1)
+
+ row2 = TQHBoxLayout(box)
+ row2.setMargin(5)
+
+ label = TQLabel("Validator: ", self)
+ row2.addWidget(label)
+
+ combo2 = TQComboBox(FALSE, self)
+ row2.addWidget(combo2)
+ combo2.insertItem("No Validator", -1)
+ combo2.insertItem("Integer Validator", -1)
+ combo2.insertItem("Double Validator", -1)
+
+ self.connect(combo2, SIGNAL("activated(int)"), self.slotValidatorChanged)
+
+ self.lined2 = TQLineEdit(self)
+ box.addWidget(self.lined2)
+
+ row3 = TQHBoxLayout(box)
+ row3.setMargin(5)
+
+ label = TQLabel("Alignment: ", self)
+ row3.addWidget(label)
+
+ combo3 = TQComboBox(FALSE, self)
+ row3.addWidget(combo3)
+ combo3.insertItem("Left", -1)
+ combo3.insertItem("Centered", -1)
+ combo3.insertItem("Right", -1)
+
+ self.connect(combo3, SIGNAL("activated(int)"), self.slotAlignmentChanged)
+ self.lined3 = TQLineEdit(self)
+ box.addWidget(self.lined3)
+
+ row4 = TQHBox(self)
+ box.addWidget(row4)
+ row4.setMargin(5)
+
+ TQLabel("Read-Only: ", row4)
+
+ combo4 = TQComboBox(FALSE, row4)
+ combo4.insertItem("False", -1)
+ combo4.insertItem("True", -1)
+
+ self.connect(combo4, SIGNAL("activated(int)"), self.slotReadOnlyChanged)
+
+ self.lined4 = TQLineEdit(self)
+ box.addWidget(self.lined4)
+
+ self.lined1.setFocus()
+
+ def slotEchoChanged(self, i):
+ if i == 0:
+ self.lined1.setEchoMode(TQLineEdit.Normal)
+ elif i == 1:
+ self.lined1.setEchoMode(TQLineEdit.Password)
+ elif i == 2:
+ self.lined1.setEchoMode(TQLineEdit.NoEcho)
+
+ self.lined1.setFocus()
+
+ def slotValidatorChanged(self, i):
+ if i == 0:
+ self.lined2.setValidator(None)
+ elif i == 1:
+ self.lined2.setValidator(TQIntValidator(self.lined2))
+ elif i == 2:
+ self.lined2.setValidator(TQDoubleValidator(-999.0, 999.0, 2, self.lined2))
+
+ self.lined2.setText("")
+ self.lined2.setFocus()
+
+ def slotAlignmentChanged(self, i):
+ if i == 0:
+ self.lined3.setAlignment(TQLineEdit.AlignLeft)
+ elif i == 1:
+ self.lined3.setAlignment(TQLineEdit.AlignCenter)
+ elif i == 2:
+ self.lined3.setAlignment(TQLineEdit.AlignRight)
+
+ self.lined3.setFocus()
+
+ def slotReadOnlyChanged(self, i):
+ if i == 0:
+ self.lined4.setReadOnly(FALSE)
+ elif i == 1:
+ self.lined4.setReadOnly(TRUE)
+
+ self.lined4.setFocus()
+
+
+if __name__=='__main__':
+ app = TQApplication( sys.argv )
+
+ lineedits = LineEdits()
+ lineedits.setCaption("Lineedits - PyTQt Example")
+ lineedits.show()
+ app.setMainWidget(lineedits)
+ app.exec_loop()
diff --git a/examples/listbox.py b/examples/listbox.py
new file mode 100755
index 0000000..fce0cc8
--- /dev/null
+++ b/examples/listbox.py
@@ -0,0 +1,176 @@
+#!/usr/bin/env python
+
+"""**************************************************************************
+** $Id: listbox.py,v 1.1 2003/05/30 17:47:57 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+
+FALSE = 0
+TRUE = 1
+
+class ListBoxDemo( TQWidget ):
+ def __init__( self, parent=None, name=None ):
+ TQWidget.__init__( self, parent, name )
+ b = FALSE
+ g = TQGridLayout( self, 2, 2, 6 )
+
+ g.addWidget( TQLabel( "<b>Configuration:</b>", self ), 0, 0 )
+ g.addWidget( TQLabel( "<b>Result:</b>", self ), 0, 1 )
+
+ self.l = TQListBox( self )
+ g.addWidget( self.l, 1, 1 )
+ self.l.setFocusPolicy( TQWidget.StrongFocus )
+
+ v = TQVBoxLayout( )
+ g.addLayout( v, 1, 0 )
+
+ bg = TQButtonGroup( self, None )
+
+ b = TQRadioButton( "Fixed number of columns,\n"
+ "as many rows as needed.",
+ self )
+ bg.insert( b )
+ v.addWidget( b )
+ b.setChecked( TRUE )
+ self.connect( b, SIGNAL("clicked()"), self.setNumCols )
+ h = TQHBoxLayout()
+ v.addLayout( h )
+ h.addSpacing( 30 )
+ h.addSpacing( 100 )
+ h.addWidget( TQLabel( "Columns:", self ) )
+ self.columns = TQSpinBox( self )
+ h.addWidget( self.columns )
+
+ v.addSpacing( 12 )
+
+ b = TQRadioButton( "As many columns as fit on-screen,\n"
+ "as many rows as needed.",
+ self )
+ bg.insert( b )
+ v.addWidget( b )
+ self.connect( b, SIGNAL("clicked()"), self.setColsByWidth )
+
+ v.addSpacing( 12 )
+
+ b = TQRadioButton( "Fixed number of rows,\n"
+ "as many columns as needed.",
+ self )
+ bg.insert( b )
+ v.addWidget( b )
+ self.connect( b, SIGNAL("clicked()"), self.setNumRows )
+ h = TQHBoxLayout()
+ v.addLayout( h )
+ h.addSpacing( 30 )
+ h.addSpacing( 100 )
+ h.addWidget( TQLabel( "Rows:", self ) )
+ self.rows = TQSpinBox( self )
+ self.rows.setEnabled( FALSE )
+ h.addWidget( self.rows )
+
+ v.addSpacing( 12 )
+
+ b = TQRadioButton( "As many rows as fit on-screen,\n"
+ "as many columns as needed.",
+ self )
+ bg.insert( b )
+ v.addWidget( b )
+ self.connect( b, SIGNAL("clicked()"), self.setRowsByHeight )
+
+ v.addSpacing( 12 )
+
+ cb = TQCheckBox( "Variable-height rows", self )
+ cb.setChecked( TRUE )
+ self.connect( cb, SIGNAL("toggled(bool)"), self.setVariableHeight )
+ v.addWidget( cb )
+ v.addSpacing( 6 )
+
+ cb = TQCheckBox( "Variable-width columns", self )
+ self.connect( cb, SIGNAL("toggled(bool)"), self.setVariableWidth )
+ v.addWidget( cb )
+
+ cb = TQCheckBox( "Extended-Selection", self )
+ self.connect( cb, SIGNAL("toggled(bool)"), self.setMultiSelection )
+ v.addWidget( cb )
+
+ pb = TQPushButton( "Sort ascending", self )
+ self.connect( pb, SIGNAL("clicked()"), self.sortAscending )
+ v.addWidget( pb )
+
+ pb = TQPushButton( "Sort descending", self )
+ self.connect( pb, SIGNAL("clicked()"), self.sortDescending )
+ v.addWidget( pb )
+
+ v.addStretch( 100 )
+
+ i = 0
+ while i <= 2560:
+ i+=1
+ self.l.insertItem( str(TQString.fromLatin1( "Item " )) + str(TQString.number( i )), i )
+ self.columns.setRange( 1, 256 )
+ self.columns.setValue( 1 )
+ self.rows.setRange( 1, 256 )
+ self.rows.setValue( 256 )
+
+ self.connect( self.columns, SIGNAL("valueChanged(int)"), self.setNumCols )
+ self.connect( self.rows, SIGNAL("valueChanged(int)"), self.setNumRows )
+
+ # slots
+ def setNumCols( self ):
+ self.columns.setEnabled( TRUE )
+ self.rows.setEnabled( FALSE )
+ self.l.setColumnMode( self.columns.value() )
+
+ def setNumRows( self ):
+ self.columns.setEnabled( FALSE )
+ self.rows.setEnabled( TRUE )
+ self.l.setRowMode( self.rows.value() )
+
+ def setRowsByHeight( self ):
+ self.columns.setEnabled( FALSE )
+ self.rows.setEnabled( FALSE )
+ self.l.setRowMode( TQListBox.FitToHeight )
+
+ def setColsByWidth( self ):
+ self.columns.setEnabled( FALSE )
+ self.rows.setEnabled( FALSE )
+ self.l.setColumnMode( TQListBox.FitToWidth )
+
+ def setVariableWidth( self, b ):
+ self.l.setVariableWidth( b )
+
+ def setVariableHeight( self, b ):
+ self.l.setVariableHeight( b )
+
+ def setMultiSelection( self, b ):
+ self.l.clearSelection()
+ if b :
+ self.l.setSelectionMode( TQListBox.Extended )
+ else:
+ self.l.setSelectionMode( TQListBox.Single )
+
+ def sortAscending( self ):
+ self.l.sort( TRUE )
+
+ def sortDescending( self ):
+ self.l.sort( FALSE )
+
+
+def main( args ):
+ a = TQApplication( args )
+ t = ListBoxDemo()
+ t.setCaption( "TQt Example - Listbox" )
+ a.setMainWidget( t )
+ t.show()
+
+ a.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/listboxcombo.py b/examples/listboxcombo.py
new file mode 100755
index 0000000..baca5d2
--- /dev/null
+++ b/examples/listboxcombo.py
@@ -0,0 +1,167 @@
+#!/usr/bin/env python
+
+"""**************************************************************************
+** $Id: listboxcombo.py,v 1.1 2003/05/30 17:47:57 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+
+FALSE = 0
+TRUE = 1
+
+class ListBoxCombo( TQVBox ):
+ # Constructor
+ # Creates child widgets of the ListBoxCombo widget
+ def __init__( self, parent=None, name=None ):
+ TQVBox.__init__( self, parent, name )
+
+ self.setMargin( 5 )
+ self.setSpacing( 5 )
+
+ i = 0
+ row1 = TQHBox( self )
+ row1.setSpacing( 5 )
+
+ # Create a multi-selection ListBox...
+ self.lb1 = TQListBox( row1 )
+ self.lb1.setSelectionMode( TQListBox.Multi )
+
+ # ...insert a pixmap item...
+ xpm = TQPixmap( "qtlogo.png" )
+ txt = TQString()
+ TQListBoxPixmap( self.lb1, xpm, txt )
+
+ # ...and 100 text items
+ for i in range(0, 100, 1) :
+ xpm = TQPixmap()
+ txt = TQString( "Listbox Item %1" ).arg( i )
+ if not i % 4 :
+ xpm = TQPixmap( "fileopen.xpm" )
+ TQListBoxPixmap( self.lb1, xpm, txt )
+
+ # Create a pushbutton...
+ arrow1 = TQPushButton( " -> ", row1 )
+ # ...and connect the clicked SIGNAL with the SLOT slotLeft2Right
+ self.connect( arrow1, SIGNAL("clicked()"), self.slotLeft2Right )
+
+ # create an empty single-selection ListBox
+ self.lb2 = TQListBox( row1 )
+
+ row2 = TQHBox( self )
+ row2.setSpacing( 5 )
+
+ box1 = TQVBox( row2 )
+ box1.setSpacing( 5 )
+
+ # Create a non-editable Combobox and a label below...
+ cb1 = TQComboBox( FALSE, box1 )
+ self.label1 = TQLabel( "Current Item: Combobox Item 0", box1 )
+ self.label1.setMaximumHeight( self.label1.sizeHint().height() * 2 )
+ self.label1.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
+
+ #...and insert 50 items into the Combobox
+ for i in range( 0, 50, 1 ) :
+ txt = str( TQString( "Combobox Item %1" ).arg( i ) )
+ if i % 9 :
+ cb1.insertItem( txt )
+ else :
+ cb1.listBox().insertItem( MyListBoxItem() )
+
+ box2 = TQVBox( row2 )
+ box2.setSpacing( 5 )
+
+ # Create an editable Combobox and a label below...
+ cb2 = TQComboBox( TRUE, box2 )
+ self.label2 = TQLabel( "Current Item: Combobox Item 0", box2 )
+ self.label2.setMaximumHeight( self.label2.sizeHint().height() * 2 )
+ self.label2.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
+
+ # ... and insert 50 items into the Combobox
+ for i in range(0, 50, 1 ) :
+ txt = str(TQString( "Combobox Item %1" ).arg( i ))
+ if not i % 4 :
+ cb2.insertItem( TQPixmap( "fileopen.xpm" ), txt )
+ else :
+ cb2.insertItem( txt )
+
+ # Connect the activated SIGNALs of the Comboboxes with SLOTs
+ self.connect( cb1, SIGNAL("activated( const TQString & )"), self.slotCombo1Activated )
+ self.connect( cb2, SIGNAL("activated( const TQString & )"), self.slotCombo2Activated )
+
+ """ SLOT slotLeft2Right
+ * Copies all selected items of the first ListBox into the second ListBox
+ """
+ def slotLeft2Right( self ):
+ # Go through all items of the first ListBox
+ for i in range( 0, self.lb1.count(), 1 ) :
+ item = self.lb1.item( i )
+ # if the item is selected...
+ if self.lb1.isSelected( i ): #item.isSelected() :
+ # ...and it is a text item...
+ if item.pixmap() and not(item.text().isEmpty()):
+ self.lb2.insertItem( item.pixmap(), item.text() )
+ elif not( item.pixmap() ):
+ self.lb2.insertItem( item.text() )
+ elif item.text().isEmpty() :
+ self.lb2.insertItem( item.pixmap() )
+
+ """ SLOT slotCombo1Activated( const TQString &s )
+ * Sets the text of the item which the user just selected in the
+ * first Combobox (and is now the value of s) to the first Label.
+ """
+ def slotCombo1Activated( self, s ) :
+ self.label1.setText( str(TQString( "Current Item: %1" ).arg( s ) ) )
+
+ """ SLOT slotCombo2Activated( const TQString &s )
+ * Sets the text of the item which the user just selected in the
+ * second Combobox (and is now the value of s) to the second Label.
+ """
+ def slotCombo2Activated( self, s ) :
+ self.label2.setText( str(TQString( "Current Item: %1" ).arg( s ) ) )
+
+
+class MyListBoxItem( TQListBoxItem ):
+ def __init__( self, parent=None, name=None ):
+ TQListBoxItem.__init__( self, parent, name )
+ self.setCustomHighlighting( TRUE )
+
+ def paint( self, painter ):
+ # evil trick: find out whether we are painted onto our listbox
+ in_list_box = 0
+ if self.listBox() and self.listBox().viewport() == painter.device():
+ in_list_box = 1
+ r = TQRect( 0, 0, self.width( self.listBox() ), self.height( self.listBox() ) )
+ brush = TQBrush( TQt.red, TQt.SolidPattern )
+ if in_list_box and isSelected():
+ painter.eraseRect( r )
+ painter.fillRect( 5, 5, self.width( self.listBox() ) - 10, self.height( self.listBox() ) - 10, brush )
+ if in_list_box and isCurrent():
+ self.listBox().style().drawPrimitive( TQStyle.PE_FocusRect, painter, r, self.listBox().colorGroup() )
+
+ def width( self, TQListBox ):
+ return 100
+
+ def height( self, TQListBox ):
+ return 16
+
+
+def main( args ):
+ a = TQApplication( args )
+
+ listboxcombo = ListBoxCombo()
+ listboxcombo.resize( 400, 270 )
+ listboxcombo.setCaption( "TQt Example - Listboxes and Comboboxes" )
+ a.setMainWidget( listboxcombo )
+ listboxcombo.show();
+
+ a.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/marble.png b/examples/marble.png
new file mode 100644
index 0000000..9c32530
--- /dev/null
+++ b/examples/marble.png
Binary files differ
diff --git a/examples/mdi.py b/examples/mdi.py
new file mode 100755
index 0000000..ca3d33b
--- /dev/null
+++ b/examples/mdi.py
@@ -0,0 +1,360 @@
+#!/usr/bin/env python
+
+# A simple application.
+
+
+import sys, string
+from python_tqt.qt import *
+
+
+fileopen = [
+ '16 13 5 1',
+ '. c #040404',
+ '# c #808304',
+ 'a c None',
+ 'b c #f3f704',
+ 'c c #f3f7f3',
+ 'aaaaaaaaa...aaaa',
+ 'aaaaaaaa.aaa.a.a',
+ 'aaaaaaaaaaaaa..a',
+ 'a...aaaaaaaa...a',
+ '.bcb.......aaaaa',
+ '.cbcbcbcbc.aaaaa',
+ '.bcbcbcbcb.aaaaa',
+ '.cbcb...........',
+ '.bcb.#########.a',
+ '.cb.#########.aa',
+ '.b.#########.aaa',
+ '..#########.aaaa',
+ '...........aaaaa'
+]
+
+filesave = [
+ '14 14 4 1',
+ '. c #040404',
+ '# c #808304',
+ 'a c #bfc2bf',
+ 'b c None',
+ '..............',
+ '.#.aaaaaaaa.a.',
+ '.#.aaaaaaaa...',
+ '.#.aaaaaaaa.#.',
+ '.#.aaaaaaaa.#.',
+ '.#.aaaaaaaa.#.',
+ '.#.aaaaaaaa.#.',
+ '.##........##.',
+ '.############.',
+ '.##.........#.',
+ '.##......aa.#.',
+ '.##......aa.#.',
+ '.##......aa.#.',
+ 'b.............'
+]
+
+fileprint = [
+ '16 14 6 1',
+ '. c #000000',
+ '# c #848284',
+ 'a c #c6c3c6',
+ 'b c #ffff00',
+ 'c c #ffffff',
+ 'd c None',
+ 'ddddd.........dd',
+ 'dddd.cccccccc.dd',
+ 'dddd.c.....c.ddd',
+ 'ddd.cccccccc.ddd',
+ 'ddd.c.....c....d',
+ 'dd.cccccccc.a.a.',
+ 'd..........a.a..',
+ '.aaaaaaaaaa.a.a.',
+ '.............aa.',
+ '.aaaaaa###aa.a.d',
+ '.aaaaaabbbaa...d',
+ '.............a.d',
+ 'd.aaaaaaaaa.a.dd',
+ 'dd...........ddd'
+]
+
+document = [
+"12 16 6 1",
+" c #040404",
+". c None",
+"X c white",
+"o c #808304",
+"O c black",
+"+ c #f3f7f3",
+" .....",
+" XXXXX ....",
+" XXXXX X ...",
+" XXXXX XX ..",
+" XooXX O.",
+" X+XXX+XXXO.",
+" XXXXXXXXXO.",
+" XoooXooXXO.",
+" XXXXXXXXXO.",
+" XXXXXXXXXO.",
+" XoXXoooXXO.",
+" XXXXXXXXXO.",
+"OXXXXXXXXXO.",
+"OXXXXXXXXXO.",
+"OOOOOOOOOOO.",
+"............"
+]
+
+fileOpenText = \
+'''<img source="fileopen">
+Click this button to open a <em>new file</em>.<br><br>
+You can also select the <b>Open</b> command from the <b>File</b> menu.'''
+
+fileSaveText = \
+'''Click this button to save the file you are editing.<br><br>
+You will be prompted for a filename.<br><br>
+You can also select the <b>Save</b> command from the <b>File</b> menu.'''
+
+filePrintText = \
+'''Click this button to print the file you are editing.<br><br>
+You can also select the <b>Print</b> command from the <b>File</b> menu.'''
+
+#True=1
+#False=0
+
+class ApplicationWindow(TQMainWindow):
+ def __init__(self):
+ TQMainWindow.__init__(self,None,'example application main window',TQt.WDestructiveClose)
+
+ self.filename = TQString.null
+ self.printer = TQPrinter()
+
+ self.fileTools = TQToolBar(self,'file operations')
+
+ openIcon = TQPixmap(fileopen)
+ self.fileOpen = TQToolButton(TQIconSet(openIcon),'Open File',TQString.null,self.load,self.fileTools,'open file')
+
+ saveIcon = TQPixmap(filesave)
+ self.fileSave = TQToolButton(TQIconSet(saveIcon),'Save File',TQString.null,self.save,self.fileTools,'save file')
+ printIcon = TQPixmap(fileprint)
+ self.filePrint = TQToolButton(TQIconSet(printIcon),'Print File',TQString.null,self.printDoc,self.fileTools,'print file')
+
+ TQWhatsThis.whatsThisButton(self.fileTools)
+
+ TQWhatsThis.add(self.fileOpen,fileOpenText)
+ TQMimeSourceFactory.defaultFactory().setPixmap('fileopen',openIcon)
+ TQWhatsThis.add(self.fileSave,fileSaveText)
+ TQWhatsThis.add(self.filePrint,filePrintText)
+
+ self.file = TQPopupMenu(self)
+ self.menuBar().insertItem('&File',self.file)
+
+ self.file.insertItem('&New',self.newDoc,TQt.CTRL + TQt.Key_N)
+
+ id = self.file.insertItem(TQIconSet(openIcon),'&Open',self.load,TQt.CTRL + TQt.Key_O)
+ self.file.setWhatsThis(id,fileOpenText)
+
+ id = self.file.insertItem(TQIconSet(saveIcon),'&Save',self.save,TQt.CTRL + TQt.Key_S)
+ self.file.setWhatsThis(id,fileSaveText)
+
+ id = self.file.insertItem('Save &as',self.saveAs)
+ self.file.setWhatsThis(id,fileSaveText)
+
+ self.file.insertSeparator()
+
+ id = self.file.insertItem(TQIconSet(printIcon),'&Print',self.printDoc,TQt.CTRL + TQt.Key_P)
+ self.file.setWhatsThis(id,filePrintText)
+
+ self.file.insertSeparator()
+
+ self.file.insertItem('&Close',self,SLOT('close()'),TQt.CTRL + TQt.Key_W)
+ self.file.insertItem('&Quit',tqApp,SLOT('closeAllWindows()'),TQt.CTRL + TQt.Key_Q)
+
+ self.menuBar().insertSeparator()
+ self.windows = TQPopupMenu( self )
+ self.windows.setCheckable( True )
+ self.connect( self.windows, SIGNAL( "aboutToShow()" ),
+ self.windowsMenuAboutToShow )
+ self.menuBar().insertItem( "&Windows", self.windows )
+
+ self.help = TQPopupMenu(self)
+ self.menuBar().insertSeparator()
+ self.menuBar().insertItem('&Help',self.help)
+
+ self.help.insertItem('&About',self.about,TQt.Key_F1)
+ self.help.insertItem('About &TQt',self.aboutTQt)
+ self.help.insertSeparator()
+ self.help.insertItem( "What's &This", self, SLOT("whatsThis()"), TQt.SHIFT+TQt.Key_F1)
+
+ self.menuBar().insertSeparator()
+
+ self.vb = TQVBox( self )
+ self.vb.setFrameStyle( TQFrame.StyledPanel | TQFrame.Sunken )
+ self.ws = TQWorkspace( self.vb )
+ self.ws.setScrollBarsEnabled( True )
+ self.setCentralWidget( self.vb )
+
+ self.statusBar().message('Ready',2000)
+ #self.resize(450,600)
+
+ def newDoc(self):
+ w = MDIWindow( self.ws, "", TQt.WDestructiveClose )
+ self.connect( w, PYSIGNAL( "message" ), self.statusBar(), SLOT( "message(const TQString&, int )") )
+ w.setCaption("unnamed document")
+ w.setIcon( TQPixmap(document) )
+ # show the very first window in maximized mode
+ if len(self.ws.windowList())==0:
+ w.showMaximized()
+ else:
+ w.show()
+ return w
+
+ def load(self):
+ fn = TQFileDialog.getOpenFileName( TQString.null, TQString.null, self )
+ if not fn.isEmpty():
+ w = self.newDoc()
+ w.load( fn )
+ else:
+ self.statusBar().message( "Loading aborted", 2000 )
+
+ def save(self):
+ m = self.ws.activeWindow()
+ if m:
+ m.save()
+
+ def saveAs(self):
+ m = self.ws.activeWindow()
+ if m:
+ m.saveAs()
+
+ def printDoc(self):
+ m = self.ws.activeWindow()
+ if m:
+ m.printDoc( self.printer )
+
+ def closeWindow(self):
+ m = self.ws.activeWindow()
+ if m:
+ m.close()
+
+ def about(self):
+ TQMessageBox.about( self, "TQt Application Example",
+ "This example demonstrates simple use of\n "
+ "TQt's Multiple Document Interface (MDI).")
+
+ def aboutTQt(self):
+ TQMessageBox.aboutTQt( self, "TQt Application Example" )
+
+ def windowsMenuAboutToShow(self):
+ self.windows.clear()
+ cascadeId = self.windows.insertItem("&Cascade", self.ws, SLOT("cascade() ") )
+ tileId = self.windows.insertItem("&Tile", self.ws, SLOT("tile()" ) )
+ if len(self.ws.windowList())==0 :
+ self.windows.setItemEnabled( cascadeId, False )
+ self.windows.setItemEnabled( tileId, False )
+ self.windows.insertSeparator()
+ windows = self.ws.windowList()
+ cnt=0
+ for i in windows:
+ id =self.windows.insertItem(i.caption(),self.windowsMenuActivated )
+ self.windows.setItemParameter( id, cnt );
+ self.windows.setItemChecked( id, self.ws.activeWindow() == i )
+ cnt=cnt+1
+
+ def windowsMenuActivated(self,sid ):
+ w = self.ws.windowList().at( id )
+ if w:
+ w.showNormal()
+ w.setFocus()
+
+
+class MDIWindow( TQMainWindow):
+ def __init__(self,parent, name, wflags ):
+ TQMainWindow.__init__(self,parent, name, wflags )
+ self.mmovie = 0
+ self.medit = TQMultiLineEdit( self )
+ self.setFocusProxy( self.medit )
+ self.setCentralWidget( self.medit );
+
+
+ def load(self, fn ):
+ self.filename = fn
+ self.f=TQFile( self.filename )
+ if not self.f.open( IO_ReadOnly ):
+ return
+
+ if fn.contains(".gif"):
+ tmp=TQWidget(self)
+ self.setFocusProxy(tmp)
+ self.setCentralWidget(tmp)
+ self.medit.hide()
+ del self.medit
+ qm=TQMovie(fn)
+ #ifdef Q_WS_QWS // temporary speed-test hack
+ #qm->setDisplayWidget(tmp);
+ #endif
+ tmp.setBackgroundMode(TQWidget.NoBackground)
+ tmp.show()
+ self.mmovie=qm
+ else :
+ self.mmovie = 0
+ t=TQTextStream(self.f)
+ s = t.read()
+ self.medit.setText( s )
+ self.f.close()
+ self.setCaption( self.filename )
+ self.emit(PYSIGNAL( "message"),(TQString("Loaded document %1").arg(self.filename),2000 ))
+
+ def save(self):
+ if self.filename.isEmpty():
+ self.saveAs()
+ return
+ text = self.medit.text()
+ output=open(str(self.filename),'w')
+ output.write(str(text))
+ #emit message( TQString("Could not write to %1").arg(filename), 2000 );
+ #return
+ output.close()
+ self.setCaption(self.filename)
+ self.emit(PYSIGNAL( "message"),(TQString("File %1 saved").arg(self.filename),2000 ))
+
+ def saveAs(self):
+ fn = TQFileDialog.getSaveFileName( self.filename, TQString.null, self )
+ if not fn.isEmpty():
+ self.filename = fn
+ self.save()
+ else :
+ self.emit(PYSIGNAL( "message"),(TQString("Saving aborted"),2000 ))
+
+ def printDoc(self,printer):
+ Margin = 10
+ pageNo = 1
+
+ if printer.setup(self):
+ self.emit(PYSIGNAL( "message"),(TQString("Printing..."),2000 ))
+ p = TQPainter()
+ p.begin(printer)
+ p.setFont(self.medit.font())
+ yPos = 0
+ fm = p.fontMetrics()
+ metrics = TQPaintDeviceMetrics(printer)
+
+ for i in range(self.medit.numLines()):
+ if Margin + yPos > metrics.height() - Margin:
+ pageNo = pageNo + 1
+ self.emit(PYSIGNAL( "message"),(TQString("Printing (page %1) ...").arg(pageNo),2000 ))
+ printer.newPage()
+ yPos = 0
+
+ p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),TQt.ExpandTabs | TQt.DontClip,self.medit.textLine(i))
+ yPos = yPos + fm.lineSpacing()
+
+ p.end()
+ self.emit(PYSIGNAL( "message"),(TQString("Printing completed"),2000 ))
+ else:
+ self.emit(PYSIGNAL( "message"),(TQString("Printing aborted"),2000 ))
+
+
+if __name__=='__main__':
+ a = TQApplication(sys.argv)
+ mw = ApplicationWindow()
+ mw.setCaption("PyTQt Example - Multiple Documents Interface (MDI)")
+ mw.show()
+ a.connect(a, SIGNAL('lastWindowClosed()'), a, SLOT('quit()'))
+ a.exec_loop()
diff --git a/examples/menu.py b/examples/menu.py
new file mode 100755
index 0000000..31fadd9
--- /dev/null
+++ b/examples/menu.py
@@ -0,0 +1,286 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: menu.py,v 1.3 2003/06/06 12:59:26 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys, string
+from python_tqt.qt import *
+
+TRUE = 1
+FALSE = 0
+
+# XPM
+p1_xpm = [
+"16 16 3 1",
+" c None",
+". c #000000000000",
+"X c #FFFFFFFF0000",
+" ",
+" ",
+" .... ",
+" .XXXX. ",
+" .............. ",
+" .XXXXXXXXXXXX. ",
+" .XXXXXXXXXXXX. ",
+" .XXXXXXXXXXXX. ",
+" .XXXXXXXXXXXX. ",
+" .XXXXXXXXXXXX. ",
+" .XXXXXXXXXXXX. ",
+" .XXXXXXXXXXXX. ",
+" .XXXXXXXXXXXX. ",
+" .XXXXXXXXXXXX. ",
+" .............. ",
+" "
+]
+
+# XPM
+p2_xpm = [
+"16 16 3 1",
+" c None",
+". c #000000000000",
+"X c #FFFFFFFFFFFF",
+" ",
+" ...... ",
+" .XXX.X. ",
+" .XXX.XX. ",
+" .XXX.XXX. ",
+" .XXX..... ",
+" .XXXXXXX. ",
+" .XXXXXXX. ",
+" .XXXXXXX. ",
+" .XXXXXXX. ",
+" .XXXXXXX. ",
+" .XXXXXXX. ",
+" .XXXXXXX. ",
+" ......... ",
+" ",
+" "
+]
+
+# XPM
+p3_xpm = [
+"16 16 3 1",
+" c None",
+". c #000000000000",
+"X c #FFFFFFFFFFFF",
+" ",
+" ",
+" ......... ",
+" ........... ",
+" ........ .. ",
+" ........... ",
+" ........... ",
+" ........... ",
+" ........... ",
+" ...XXXXX... ",
+" ...XXXXX... ",
+" ...XXXXX... ",
+" ...XXXXX... ",
+" ......... ",
+" ",
+" "
+]
+
+
+# Auxiliary class to provide fancy menu items with different fonts.
+# Used for the "bold" and "underline" menu items in the options menu.
+
+class MyMenuItem( TQCustomMenuItem ):
+ def __init__( self, s, f ):
+ TQCustomMenuItem.__init__( self )
+ self.string = s
+ self.font = f
+
+ def paint( self, p, cg, act, enabled, x, y, w, h ) :
+ p.setFont ( self.font )
+ p.drawText( x, y, w, h, TQt.AlignLeft | TQt.AlignVCenter | TQt.ShowPrefix | TQt.DontClip, self.string )
+
+ def sizeHint( self ):
+ return TQFontMetrics( self.font ).size( TQt.AlignLeft | TQt.AlignVCenter | TQt.ShowPrefix | TQt.DontClip, self.string )
+
+
+# Implementation of MenuExample class
+
+class MenuExample( TQWidget ):
+ def __init__( self, parent=None, name=None ):
+ TQWidget.__init__( self, parent, name )
+ self.p1 = TQIconSet( TQPixmap ( p1_xpm ) )
+ self.p2 = TQIconSet( TQPixmap ( p2_xpm ) )
+ self.p3 = TQIconSet( TQPixmap ( p3_xpm ) )
+
+ self.printer = TQPopupMenu( self )
+ self.printer.insertTearOffHandle()
+ self.printer.insertItem( "&Print to printer", self.printDoc )
+ self.printer.insertItem( "Print to &file", self.printFile )
+ self.printer.insertItem( "Print to fa&x", self.fax )
+ self.printer.insertSeparator()
+ self.printer.insertItem( "Printer &Setup", self.printerSetup )
+
+ self.file = TQPopupMenu( self )
+ self.file.insertItem( self.p1, "&Open", self.open, TQt.CTRL+TQt.Key_O )
+ self.file.insertItem( self.p2, "&New", self.news, TQt.CTRL+TQt.Key_N )
+ self.file.insertItem( self.p3, "&Save", self.save, TQt.CTRL+TQt.Key_S )
+ self.file.insertItem( "&Close", self.closeDoc, TQt.CTRL+TQt.Key_W )
+ self.file.insertSeparator()
+ self.file.insertItem( "&Print", self.printer, TQt.CTRL+TQt.Key_P )
+ self.file.insertSeparator()
+ self.file.insertItem( "E&xit", tqApp, SLOT( "quit()" ), TQt.CTRL+TQt.Key_Q )
+
+ self.edit = TQPopupMenu( self )
+ undoID = self.edit.insertItem( "&Undo", self.undo )
+ redoID = self.edit.insertItem( "&Redo", self.redo )
+ self.edit.setItemEnabled( undoID, FALSE )
+ self.edit.setItemEnabled( redoID, FALSE )
+
+ self.options = TQPopupMenu( self )
+ self.options.insertTearOffHandle()
+ self.options.setCaption( "Options" )
+ self.options.insertItem( "&Normal Font", self.normal )
+ self.options.insertSeparator()
+
+ self.options.polish() # adjust system settings
+ f = self.options.font()
+ f.setBold( TRUE )
+ self.boldID = self.options.insertItem( MyMenuItem( "Bold", f ) )
+ self.options.setAccel( TQt.CTRL+TQt.Key_B, self.boldID )
+ self.options.connectItem( self.boldID, self.bold )
+
+ f = self.options.font()
+ f.setUnderline( TRUE )
+ self.underlineID = self.options.insertItem( MyMenuItem( "Underline", f ) )
+ self.options.setAccel( TQt.CTRL+TQt.Key_U, self.underlineID )
+ self.options.connectItem( self.underlineID, self.underline )
+
+ self.isBold = FALSE
+ self.isUnderline = FALSE
+ self.options.setCheckable( TRUE )
+
+ self.help = TQPopupMenu( self )
+ self.help.insertItem( "&About", self.about, TQt.CTRL+TQt.Key_H )
+ self.help.insertItem( "About &TQt", self.aboutTQt )
+
+ self.menu = TQMenuBar( self )
+ self.menu.insertItem( "&File", self.file )
+ self.menu.insertItem( "&Edit", self.edit )
+ self.menu.insertItem( "&Options", self.options )
+ self.menu.insertSeparator()
+ self.menu.insertItem( "&Help", self.help )
+ self.menu.setSeparator( TQMenuBar.InWindowsStyle )
+
+ msg = TQLabel( self )
+ msg.setText( "A context menu is available.\n"
+ "Invoke it by right-clicking or by"
+ " pressing the 'context' button." )
+ msg.setGeometry( 0, self.height() - 60, self.width(), 60 )
+ msg.setAlignment( TQt.AlignCenter )
+
+ self.label = TQLabel( self )
+ self.label.setGeometry( 20, self.rect().center().y()-20, self.width()-40, 40 )
+ self.label.setFrameStyle( TQFrame.Box | TQFrame.Raised )
+ self.label.setLineWidth( 1 )
+ self.label.setAlignment( TQt.AlignCenter )
+
+ self.connect( self, PYSIGNAL( "explain" ), self.label, SLOT( "setText(const TQString &" ) )
+
+ self.setMinimumSize( 100, 80 )
+ self.setFocusPolicy( TQWidget.ClickFocus )
+
+ def contextMenuEvent(self, cmev):
+ contextMenu = TQPopupMenu( self )
+ caption = TQLabel( "<font color=darkblue><u><b>Context Menu</b></u></font>", self )
+ caption.setAlignment( TQt.AlignCenter )
+ contextMenu.insertItem( caption )
+ contextMenu.insertItem( "&New", self.news, TQt.CTRL+TQt.Key_N )
+ contextMenu.insertItem( "&Open...", self.open, TQt.CTRL+TQt.Key_O )
+ contextMenu.insertItem( "&Save", self.save, TQt.CTRL+TQt.Key_S )
+ submenu = TQPopupMenu( self )
+ submenu.insertItem( "&Print to printer", self.printDoc )
+ submenu.insertItem( "Print to &file", self.printFile )
+ submenu.insertItem( "Print to fa&x", self.fax )
+ contextMenu.insertItem( "&Print", submenu )
+ contextMenu.exec_loop( TQCursor.pos() )
+
+ def open( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "File/Open selected", ) )
+
+ def news( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "File/New selected", ) )
+
+ def save( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "File/Save selected", ) )
+
+ def closeDoc( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "File/Close selected", ) )
+
+ def undo( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "Edit/Undo selected", ) )
+
+ def redo( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "Edit/Redo selected", ) )
+
+ def normal( self ):
+ self.isBold = FALSE
+ self.isUnderline = FALSE
+ font = TQFont()
+ self.label.setFont( font )
+ self.options.setItemChecked( self.boldID, self.isBold )
+ self.options.setItemChecked( self.underlineID, self.isUnderline )
+ self.emit( PYSIGNAL( "explain" ), ( "Options/Normal selected", ) )
+
+ def bold( self ):
+ self.isBold = not self.isBold
+ font = TQFont()
+ font.setBold( self.isBold )
+ font.setUnderline( self.isUnderline )
+ self.label.setFont( font )
+ self.options.setItemChecked( self.boldID, self.isBold )
+ self.emit( PYSIGNAL( "explain" ), ( "Options/Bold selected", ) )
+
+ def underline( self ):
+ self.isUnderline = not self.isUnderline
+ font = TQFont()
+ font.setBold( self.isBold )
+ font.setUnderline( self.isUnderline )
+ self.label.setFont( font )
+ self.options.setItemChecked( self.underlineID, self.isUnderline )
+ self.emit( PYSIGNAL("explain"), ( "Options/Underline selected", ))
+
+ def about( self ):
+ TQMessageBox.about( self, "TQt Menu Example",
+ "This example demonstrates simple use of TQt menus.\n"
+ "You can cut and paste lines from it to your own\n"
+ "programs." )
+
+ def aboutTQt( self ):
+ TQMessageBox.aboutTQt( self, "TQt Menu Example" )
+
+ def printDoc( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "File/Printer/Print selected", ) )
+
+ def printFile( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "File/Printer/Print To File selected", ) )
+
+ def fax( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "File/Printer/Print To Fax selected", ) )
+
+ def printerSetup( self ):
+ self.emit( PYSIGNAL( "explain" ), ( "File/Printer/Printer Setup selected", ) )
+
+ def resizeEvent( self, ev ):
+ self.label.setGeometry( 20, self.rect().center().y()-20, self.width()-40, 40 )
+
+
+a = TQApplication( sys.argv )
+m = MenuExample()
+
+m.setCaption( "TQt Examples - Menus" )
+a.setMainWidget( m )
+m.show()
+a.exec_loop()
diff --git a/examples/progress.py b/examples/progress.py
new file mode 100755
index 0000000..3ebdd12
--- /dev/null
+++ b/examples/progress.py
@@ -0,0 +1,281 @@
+#!/usr/bin/env python
+
+#/****************************************************************************
+#** $Id: progress.py 3.3.7 edited Aug 31 2005 $
+#**
+#** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
+#**
+#** This file is part of an example program for TQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#** Converted to PyTQt3 by Hans-Peter Jansen <hpj@urpla.net>
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+from random import randint
+
+class AnimatedThingy(TQLabel):
+ def __init__(self, parent, s):
+ TQLabel.__init__(self, parent)
+ self.label = TQString(s)
+ self.setEraseColor(TQt.white)
+ self.label.append("\n... and wasting CPU\nwith this animation!\n")
+ self.step = 0
+ self.nqix = 10
+ self.stepoff = 2
+ self.stepmax = 7
+ self.lwidth = 2
+ self.tdelay = 100
+ self.ox, self.oy = [], []
+ for i in range(self.nqix):
+ self.ox.append((0, 0))
+ self.oy.append((0, 0))
+ self.x0, self.y0, self.x1, self.y1 = 0, 0, 0, 0
+ self.dx0 = randint(0, self.stepmax) + self.stepoff
+ self.dy0 = randint(0, self.stepmax) + self.stepoff
+ self.dx1 = randint(0, self.stepmax) + self.stepoff
+ self.dy1 = randint(0, self.stepmax) + self.stepoff
+
+ def show(self):
+ if not self.isVisible():
+ self.startTimer(self.tdelay)
+ TQWidget.show(self)
+
+ def hide(self):
+ TQWidget.hide(self)
+ self.killTimers()
+
+ def sizeHint(self):
+ return TQSize(120, 100)
+
+ def timerEvent(self, e):
+ p, pn = self._painter()
+ pn.setColor(self.eraseColor())
+ p.setPen(pn)
+ self.step = step = (self.step + 1) % self.nqix
+ # erase line
+ p.drawLine(self.ox[step][0], self.oy[step][0],
+ self.ox[step][1], self.oy[step][1])
+ # calc new line coordinates
+ ww, wh = self.width(), self.height()
+ self.x0, self.dx0 = self._inc(self.x0, self.dx0, ww)
+ self.y0, self.dy0 = self._inc(self.y0, self.dy0, wh)
+ self.x1, self.dx1 = self._inc(self.x1, self.dx1, ww)
+ self.y1, self.dy1 = self._inc(self.y1, self.dy1, wh)
+ self.ox[step] = (self.x0, self.x1)
+ self.oy[step] = (self.y0, self.y1)
+ self._drawqix(p, pn, step)
+ self._drawtxt(p)
+
+ def paintEvent(self, event):
+ p, pn = self._painter()
+ p.setClipRect(event.rect())
+ for i in range(self.nqix):
+ self._drawqix(p, pn, i)
+ self._drawtxt(p)
+
+ def _painter(self):
+ p = TQPainter(self)
+ # we need to create a new pen from p.pen() with TQPen() in order
+ # to make it fully functional (changes are discarded otherwise)
+ pn = TQPen(p.pen())
+ pn.setWidth(self.lwidth)
+ p.setPen(pn)
+ return p, pn
+
+ def _drawqix(self, p, pn, step):
+ # rainbow effect
+ pn.setColor(TQColor(int((step * 255)/self.nqix), 255, 255, TQColor.Hsv))
+ p.setPen(pn)
+ p.drawLine(self.ox[step][0], self.oy[step][0],
+ self.ox[step][1], self.oy[step][1])
+
+ def _drawtxt(self, p):
+ p.setPen(self.colorGroup().text())
+ p.drawText(self.rect(), TQt.AlignCenter, self.label)
+
+ def _inc(self, x, dx, b):
+ x += dx
+ if x < 0:
+ x = 0
+ dx = randint(0, self.stepmax) + self.stepoff;
+ elif x >= b:
+ x = b - 1
+ dx = -(randint(0, self.stepmax) + self.stepoff)
+ return x, dx
+
+
+class CPUWaster(TQWidget):
+ def __init__(self):
+ TQWidget.__init__(self)
+ self.first_draw_item = 1000
+ self.last_draw_item = 1006
+ self.rects = 0
+ self.timer_driven = 0
+ self.default_label = 0
+ self.got_stop = False
+ self.pb = None # non modal progress dialog
+ self.menubar = menubar = TQMenuBar(self, "menu")
+ self.file_ = file_ = TQPopupMenu()
+ menubar.insertItem("&File", file_)
+ for i in range(self.first_draw_item, self.last_draw_item + 1):
+ file_.insertItem(self.drawItemText(i), i)
+ file_.setAccel(TQKeySequence(
+ "Ctrl+%s" % (i - self.first_draw_item)), i)
+ self.connect(menubar, SIGNAL("activated(int)"), self.doMenuItem)
+ file_.insertSeparator()
+ file_.insertItem("Quit", tqApp, SLOT("quit()"), TQKeySequence("Ctrl+Q"))
+ self.options = options = TQPopupMenu()
+ menubar.insertItem("&Options", options)
+ self.ld_id = options.insertItem("Loop driven", self.loopDriven,
+ TQKeySequence("Alt+L"))
+ self.td_id = options.insertItem("Timer driven", self.timerDriven,
+ TQKeySequence("Alt+T"))
+ options.insertSeparator()
+ self.dl_id = options.insertItem("Default label", self.defaultLabel,
+ TQKeySequence("Alt+D"))
+ self.cl_id = options.insertItem("Custom label", self.customLabel,
+ TQKeySequence("Alt+C"))
+ options.insertSeparator()
+ self.md_id = options.insertItem("No minimum duration",
+ self.toggleMinimumDuration,
+ TQKeySequence("Alt+M"))
+ options.setCheckable(True)
+ # default option settings
+ self.timerDriven()
+ self.customLabel()
+ self.toggleMinimumDuration()
+ self.resize(400, 300)
+ self.setEraseColor(TQt.black)
+
+ def drawItemRects(self, id_):
+ r = 100
+ for n in range(id_ - self.first_draw_item):
+ if not n % 3:
+ r *= 4
+ else:
+ r *= 5
+ return r
+
+ def drawItemText(self, id_):
+ return TQString("%d Rectangles" % self.drawItemRects(id_))
+
+ def enableDrawingItems(self, yes):
+ for i in range(self.first_draw_item, self.last_draw_item + 1):
+ self.menubar.setItemEnabled(i, yes)
+
+ # slots
+ def doMenuItem(self, id_):
+ if id_ >= self.first_draw_item and id_ <= self.last_draw_item:
+ self.draw(self.drawItemRects(id_))
+
+ def timerDriven(self):
+ self.timer_driven = True
+ self.options.setItemChecked(self.td_id, True)
+ self.options.setItemChecked(self.ld_id, False)
+
+ def loopDriven(self):
+ self.timer_driven = False
+ self.options.setItemChecked(self.ld_id, True)
+ self.options.setItemChecked(self.td_id, False)
+
+ def defaultLabel(self):
+ self.default_label = True
+ self.options.setItemChecked(self.dl_id, True)
+ self.options.setItemChecked(self.cl_id, False)
+
+ def customLabel(self):
+ self.default_label = False
+ self.options.setItemChecked(self.dl_id, False)
+ self.options.setItemChecked(self.cl_id, True)
+
+ def toggleMinimumDuration(self):
+ self.options.setItemChecked(self.md_id,
+ not self.options.isItemChecked(self.md_id))
+
+ def stopDrawing(self):
+ self.got_stop = True
+
+ def newProgressDialog(self, label, steps, modal):
+ d = TQProgressDialog(label, "Cancel", steps, self, "progress", modal)
+ if self.options.isItemChecked(self.md_id):
+ d.setMinimumDuration(0)
+ if not self.default_label:
+ d.setLabel(AnimatedThingy(d, label))
+ d.setCaption("Please Wait")
+ return d
+
+ def draw(self, n):
+ if self.timer_driven:
+ if self.pb:
+ tqWarning("This cannot happen!")
+ return
+
+ self.rects = n
+ self.pb = self.newProgressDialog("Drawing rectangles.\n"
+ "Using timer event.", n, False)
+ self.connect(self.pb, SIGNAL("cancelled()"), self.stopDrawing)
+ self.enableDrawingItems(False)
+ self.startTimer(0)
+ self.got_stop = False
+ else: # loop driven with modal progress dialog
+ lpb = self.newProgressDialog("Drawing rectangles.\n"
+ "Using loop.", n, True)
+ p = TQPainter(self)
+ for i in range(n):
+ lpb.setProgress(i)
+ if lpb.wasCancelled():
+ break
+ self._draw(p)
+ self._clear(p)
+ lpb.cancel()
+ del lpb
+
+ def timerEvent(self, e):
+ if not self.got_stop:
+ self.pb.setProgress(self.pb.totalSteps() - self.rects)
+ self.rects -= 1
+ p = TQPainter(self)
+ self._draw(p)
+
+ if not self.rects or self.got_stop:
+ if not self.got_stop:
+ self.pb.setProgress(self.pb.totalSteps())
+ self._clear(p)
+ self.enableDrawingItems(True)
+ self.killTimers()
+ self.pb.cancel()
+ del self.pb
+ self.pb = None
+
+ def _draw(self, p):
+ ww = self.width()
+ wh = self.height()
+ if ww > 8 and wh > 8:
+ c = TQColor(randint(0, 255), randint(0, 255), randint(0, 255))
+ x = randint(0, ww - 8)
+ y = randint(0, wh - 8)
+ w = randint(0, ww - x)
+ h = randint(0, wh - y)
+ p.fillRect(x, y, w, h, TQBrush(c))
+
+ def _clear(self, p):
+ p.fillRect(0, 0, self.width(), self.height(), TQBrush(self.eraseColor()))
+
+
+if __name__ == "__main__":
+ app = TQApplication(sys.argv)
+ try:
+ n = int(sys.argv[1])
+ except:
+ n = 1
+ wlst = [] # keep a ref around
+ for i in range(n):
+ cpuw = CPUWaster()
+ if i == 0:
+ app.setMainWidget(cpuw)
+ cpuw.show()
+ wlst.append(cpuw)
+ app.exec_loop()
diff --git a/examples/progressbar.py b/examples/progressbar.py
new file mode 100755
index 0000000..e33362e
--- /dev/null
+++ b/examples/progressbar.py
@@ -0,0 +1,155 @@
+#!/usr/bin/env python
+
+"""***********************************************************************
+** $Id: progressbar.py,v 1.1 2003/06/10 14:51:24 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+**************************************************************************"""
+
+#import pdb
+import sys
+from python_tqt.qt import *
+
+FALSE = 0
+TRUE = 1
+
+class ProgressBar( TQButtonGroup ):
+ # Constructor
+ # Creates child widgets of the ProgressBar widget
+ def __init__( self, parent=None, name=None ):
+ TQButtonGroup.__init__( self, 0, TQt.Horizontal, "Progress Bar", parent, name )
+
+ self.timer = TQTimer()
+
+ self.setMargin( 10 )
+ toplayout = TQGridLayout( self.layout(), 2, 2, 5)
+
+ self.setRadioButtonExclusive( TRUE )
+
+ # insert three radiobuttons which the user can use
+ # to set the speed of the progress and two pushbuttons
+ # to start/pause/continue and reset the progress
+ self.slow = TQRadioButton( "&Slow", self )
+ self.normal = TQRadioButton( "&Normal", self )
+ self.fast = TQRadioButton( "&Fast", self )
+ vb1 = TQVBoxLayout( )
+ toplayout.addLayout( vb1, 0, 0 )
+ vb1.addWidget( self.slow )
+ vb1.addWidget( self.normal )
+ vb1.addWidget( self.fast )
+
+ # two push buttons, one for start, for for reset.
+ self.start = TQPushButton( "&Start", self )
+ self.reset = TQPushButton( "&Reset", self )
+
+ vb2 = TQVBoxLayout()
+ toplayout.addLayout( vb2, 0, 1 )
+ vb2.addWidget( self.start )
+ vb2.addWidget( self.reset )
+
+ # Create the progressbar
+ self.progress = TQProgressBar( 100, self )
+ #self.progress.setStyle( TQMotifStyle() )
+ toplayout.addMultiCellWidget( self.progress, 1, 1, 0, 1 )
+
+ # connect the clicked() SIGNALs of the pushbuttons to SLOTs
+ self.connect( self.start, SIGNAL("clicked()"), self.slotStart )
+ self.connect( self.reset, SIGNAL("clicked()"), self.slotReset )
+
+ # connect the timeout() SIGNAL of the progress-timer to a SLOT
+ self.connect( self.timer, SIGNAL("timeout()"), self.slotTimeout )
+ # Let's start with normal speed...
+ self.normal.setChecked( TRUE )
+
+ # some contraints
+ self.start.setFixedWidth( 80 )
+ self.setMinimumWidth( 300 )
+
+ # SLOT slotStart
+ # This SLOT is called if the user clicks start/pause/continue button
+ def slotStart( self ):
+ # If the progress bar is at the beginning...
+ if self.progress.progress() == -1 :
+ # ...set according to the checked speed-radiobutton the
+ # the number of steps which are needed to complete the process
+ if self.slow.isChecked():
+ self.progress.setTotalSteps( 10000 )
+ elif self.normal.isChecked() :
+ self.progress.setTotalSteps( 1000 )
+ else :
+ self.progress.setTotalSteps( 50 )
+
+ # disable the speed-radiobuttons
+ self.slow.setEnabled( FALSE )
+ self.normal.setEnabled( FALSE )
+ self.fast.setEnabled( FALSE )
+
+ # If the progress is not running...
+ if not self.timer.isActive() :
+ # ...start the timer (and so the progress) with a interval of 1 ms...
+ self.timer.start( 1 )
+ # ...and rename the start/pause/continue button to Pause
+ self.start.setText( "&Pause" )
+ else : # if the prgress is running...
+ # ...stop the timer (and so the prgress)...
+ self.timer.stop()
+ # ...and rename the start/pause/continue button to Continue
+ self.start.setText( "&Continue" )
+
+ # SLOT slotReset
+ # This SLOT is called when the user clicks the reset button
+ def slotReset( self ):
+ # stop the timer and progress
+ self.timer.stop()
+
+ # rename the start/pause/continue button to Start...
+ self.start.setText( "&Start" )
+ # ...and enable this button
+ self.start.setEnabled( TRUE )
+
+ # enable the speed-radiobuttons
+ self.slow.setEnabled( TRUE )
+ self.normal.setEnabled( TRUE )
+ self.fast.setEnabled( TRUE )
+
+ # reset the progressbar
+ self.progress.reset()
+
+ # SLOT slotTimeout
+ # This SLOT is called each ms when the timer is
+ # active (== progress is running)
+ def slotTimeout( self ):
+ p = self.progress.progress()
+
+ # If the progress is complete...
+ if p == self.progress.totalSteps() :
+ # ...rename the start/pause/continue button to Start...
+ self.start.setText( "&Start" )
+ # ...and disable it...
+ self.start.setEnabled( FALSE )
+ # ...and return
+ return
+
+ # If the process is not complete increase it
+ p += 1
+ self.progress.setProgress( p )
+
+
+ #TQPushButton *start, *pause, *reset;
+
+def main( args ):
+ a = TQApplication( args )
+
+ progressbar = ProgressBar()
+ progressbar.setCaption("TQt Example - ProgressBar")
+ a.setMainWidget(progressbar)
+ progressbar.show()
+
+ a.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/qdir.py b/examples/qdir.py
new file mode 100755
index 0000000..358c796
--- /dev/null
+++ b/examples/qdir.py
@@ -0,0 +1,324 @@
+#!/usr/bin/env python
+#
+# 2005-02-12 initial version hp
+
+from __future__ import print_function
+import os
+import pickle
+from python_tqt.qt import *
+from dirview import Directory, DirectoryView
+
+bookmarks = [
+ "22 14 8 1",
+ "# c #000080",
+ "a c #585858",
+ "b c #000000",
+ "c c #ffffff",
+ "d c #ffffff",
+ "e c #ffffff",
+ "f c #000000",
+ ". c None",
+ "...bb.................",
+ "..bacb....bbb.........",
+ "..badcb.bbccbab.......",
+ "..bacccbadccbab.......",
+ "..baecdbcccdbab.......",
+ "..bacccbacccbab.......",
+ "..badcdbcecdfab.......",
+ "..bacecbacccbab.......",
+ "..baccdbcccdbab.......",
+ "...badcbacdbbab.......",
+ "....bacbcbbccab.......",
+ ".....babbaaaaab.......",
+ ".....bbabbbbbbb.......",
+ "......bb.............."
+]
+
+home = [
+ "16 15 4 1",
+ "# c #000000",
+ "a c #ffffff",
+ "b c #c0c0c0",
+ ". c None",
+ ".......##.......",
+ "..#...####......",
+ "..#..#aabb#.....",
+ "..#.#aaaabb#....",
+ "..##aaaaaabb#...",
+ "..#aaaaaaaabb#..",
+ ".#aaaaaaaaabbb#.",
+ "###aaaaaaaabb###",
+ "..#aaaaaaaabb#..",
+ "..#aaa###aabb#..",
+ "..#aaa#.#aabb#..",
+ "..#aaa#.#aabb#..",
+ "..#aaa#.#aabb#..",
+ "..#aaa#.#aabb#..",
+ "..#####.######.."
+]
+
+
+class PixmapView(TQScrollView):
+ def __init__(self, parent):
+ TQScrollView.__init__(self, parent)
+ self.pixmap = None
+ self.viewport().setBackgroundMode(self.PaletteBase)
+
+ def setPixmap(self, pix):
+ self.pixmap = pix
+ self.resizeContents(pix.size().width(), pix.size().height())
+ self.viewport().repaint(False)
+
+ def drawContents(self, p, cx, cy, cw, ch):
+ p.fillRect(cx, cy, cw, ch, self.colorGroup().brush(TQColorGroup.Base))
+ p.drawPixmap(0, 0, self.pixmap)
+
+
+class Preview(TQWidgetStack):
+ def __init__(self, parent):
+ TQWidgetStack.__init__(self, parent)
+ self.normalText = TQMultiLineEdit(self)
+ self.normalText.setReadOnly(True)
+ self.html = TQTextView(self)
+ self.pixmap = PixmapView(self)
+ self.raiseWidget(self.normalText)
+
+ def showPreview(self, url, size):
+ if url.isLocalFile():
+ path = url.path()
+ fi = TQFileInfo(path)
+ if fi.isFile() and fi.size() > size * 1000:
+ self.normalText.setText(
+ "The File\n%s\nis too large, so I don't show it!" % path)
+ self.raiseWidget(self.normalText)
+ return
+ pix = TQPixmap(path)
+ if pix.isNull():
+ if fi.isFile():
+ err = False
+ try:
+ text = open(path.latin1(), "r").read()
+ except IOError as msg:
+ text = TQString(str(msg))
+ err = True
+ if not err and fi.extension().lower().contains("htm"):
+ url = self.html.mimeSourceFactory().makeAbsolute(
+ path, self.html.context())
+ self.html.setText(text, url)
+ self.raiseWidget(self.html)
+ return
+ else:
+ self.normalText.setText(text)
+ self.raiseWidget(self.normalText)
+ return
+ else:
+ self.normalText.setText("")
+ self.raiseWidget(self.normalText)
+ else:
+ self.pixmap.setPixmap(pix)
+ self.raiseWidget(self.pixmap)
+ else:
+ self.normalText.setText("I only show local files!")
+ self.raiseWidget(self.normalText)
+
+
+# We can't instantiate TQFilePreview directly because it is abstract. Note that
+# the previewUrl() abstract is patched in later to work around the fact that
+# you can't multiply inherit from more than one wrapped class.
+class FilePreview(TQFilePreview):
+ pass
+
+
+class PreviewWidget(TQVBox):
+ def __init__(self, parent):
+ TQVBox.__init__(self, parent)
+ self.setSpacing( 5 )
+ self.setMargin( 5 )
+ row = TQHBox(self)
+ row.setSpacing(5)
+ TQLabel("Only show files smaller than: ", row)
+ self.sizeSpinBox = TQSpinBox(1, 10000, 1, row)
+ self.sizeSpinBox.setSuffix(" KB")
+ self.sizeSpinBox.setValue(128)
+ row.setFixedHeight(10 + self.sizeSpinBox.sizeHint().height())
+ self.__preview = Preview(self)
+ # workaround sip inability of multiple inheritance
+ # create a local TQFilePreview instance and redirect
+ # the method, which is called on preview, to us
+ self.preview = FilePreview()
+ self.preview.previewUrl = self.previewUrl
+
+ def previewUrl(self, url):
+ self.__preview.showPreview(url, self.sizeSpinBox.value())
+
+
+class CustomFileDialog(TQFileDialog):
+ def __init__(self, preview = False):
+ TQFileDialog.__init__(self, None, None, True)
+ self.bookmarkFile = ".pybookmarks"
+ self.bookmarkList = []
+ if os.path.exists(self.bookmarkFile):
+ try:
+ self.bookmarkList = pickle.loads(open(self.bookmarkFile, "rb").read())
+ except IOError as msg:
+ print(msg)
+ self.setDir("/")
+ self.dirView = DirectoryView(self, None, True)
+ self.dirView.addColumn("")
+ self.dirView.header().hide()
+ root = Directory(self.dirView, "/")
+ root.setOpen(True)
+ self.dirView.setFixedWidth(200)
+ self.addLeftWidget(self.dirView)
+ p = TQPushButton(self)
+ p.setPixmap(TQPixmap(bookmarks))
+ TQToolTip.add(p, "Bookmarks")
+ self.bookmarkMenu = TQPopupMenu(self)
+ self.connect(self.bookmarkMenu, SIGNAL("activated(int)"),
+ self.bookmarkChosen)
+ self.addId = self.bookmarkMenu.insertItem("Add bookmark")
+ self.bookmarkMenu.insertSeparator()
+ for l in self.bookmarkList:
+ self.bookmarkMenu.insertItem(l)
+ p.setPopup(self.bookmarkMenu)
+ self.addToolButton(p, True)
+ self.connect(self.dirView, PYSIGNAL("folderSelected(const TQString &)"),
+ self.setDir2)
+ self.connect(self, SIGNAL("dirEntered(const TQString &)"),
+ self.dirView.setDir)
+ b = TQToolButton(self)
+ TQToolTip.add(b, "Go Home!")
+ b.setPixmap(TQPixmap(home))
+ self.connect(b, SIGNAL("clicked()"), self.goHome)
+ self.addToolButton(b)
+
+ if preview:
+ self.setContentsPreviewEnabled(True)
+ pw = PreviewWidget(self)
+ self.setContentsPreview(pw, pw.preview)
+ self.setViewMode(TQFileDialog.List)
+ self.setPreviewMode(TQFileDialog.Contents)
+
+ w = self.width()
+ h = self.height()
+ if preview:
+ self.resize(w + w / 2, h + h / 3)
+ else:
+ self.resize(w + w / 3, h + h / 4)
+
+ def done(self, r):
+ if self.bookmarkList:
+ try:
+ open(self.bookmarkFile, "wb").write(pickle.dumps(self.bookmarkList))
+ except IOError as msg:
+ print(msg)
+ return TQFileDialog.done(self, r)
+
+ def showEvent(self, e):
+ TQFileDialog.showEvent(self, e)
+ self.dirView.setDir(self.dirPath())
+
+ def setDir2(self, path):
+ self.blockSignals(True)
+ self.setDir(path)
+ self.blockSignals(False)
+
+ def bookmarkChosen(self, i):
+ if i == self.addId:
+ # keep bookmarks pythonic
+ dp = self.dirPath().latin1()
+ if dp not in self.bookmarkList:
+ self.bookmarkList.append(dp)
+ self.bookmarkMenu.insertItem(dp)
+ else:
+ self.setDir(self.bookmarkMenu.text(i))
+
+ def goHome(self):
+ if os.getenv("HOME"):
+ self.setDir(os.getenv("HOME"))
+ else:
+ self.setDir("/")
+
+
+if __name__ == '__main__':
+ import sys
+ import getopt
+
+ def usage(msg = None):
+ if msg:
+ print(msg, file=sys.stderr)
+ print("""\
+usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [caption ...]
+ --any Get any filename, need not exist.
+ --dir Return a directory rather than a file.
+ --custom Opens a customized TQFileDialog with
+ dir browser, bookmark menu, etc.
+ --preview Show a preview widget.
+ --default f Start from directory/file f.
+ --filter f eg. '*.gif' '*.bmp'
+ caption ... Caption for dialog.
+""", file=sys.stderr)
+ sys.exit(1)
+
+ def main():
+ options = ["help", "any", "dir", "custom", "preview", "default=", "filter="]
+ mode = TQFileDialog.ExistingFile
+ preview = False
+ custom = False
+ start = None
+ filter = TQString.null
+ app = TQApplication(sys.argv)
+
+ try:
+ optlist, args = getopt.getopt(sys.argv[1:], "h", options)
+ except getopt.error as msg:
+ usage(msg)
+
+ for opt, par in optlist:
+ if opt in ("-h", "--help"):
+ usage()
+ elif opt == "--any":
+ mode = TQFileDialog.AnyFile
+ elif opt == "--dir":
+ mode = TQFileDialog.Directory
+ elif opt == "--default":
+ start = par
+ elif opt == "--filter":
+ filter = par
+ elif opt == "--preview":
+ preview = True
+ elif opt == "--custom":
+ custom = True
+ if args:
+ caption = " ".join(args)
+ elif mode == TQFileDialog.Directory:
+ caption = "Choose directory..."
+ else:
+ caption = "Choose file..."
+ if not start:
+ start = TQDir.currentDirPath()
+ if not custom:
+ fd = TQFileDialog(TQString.null, filter, None, None, True)
+ fd.setMode(mode)
+ if preview:
+ fd.setContentsPreviewEnabled(True)
+ pw = PreviewWidget(fd)
+ fd.setContentsPreview(pw, pw.preview)
+ fd.setViewMode(TQFileDialog.List)
+ fd.setPreviewMode(TQFileDialog.Contents)
+ w = fd.width()
+ h = fd.height()
+ fd.resize(w + w / 3, h + h / 4)
+ fd.setCaption(caption)
+ fd.setSelection(start)
+ if fd.exec_loop() == TQDialog.Accepted:
+ print("%s\n" % fd.selectedFile().latin1())
+ return 0
+ else:
+ return 1
+ else:
+ fd = CustomFileDialog(preview)
+ fd.exec_loop()
+ return 1
+
+ sys.exit(main())
diff --git a/examples/qmag.py b/examples/qmag.py
new file mode 100755
index 0000000..186a473
--- /dev/null
+++ b/examples/qmag.py
@@ -0,0 +1,233 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: qmag.py,v 1.1 2002/06/20 18:52:31 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+
+TRUE = 1
+FALSE = 0
+
+zoomfactors = ["100%","200%","300%","400%","500%","600%","700%","800%","1600%"]
+
+refreshrates = [
+ "No autorefresh", "50 per second", "4 per second", "3 per second",
+ "2 per second", "Every second", "Every two seconds", "Every three seconds",
+ "Every five seconds", "Every ten seconds"]
+
+timer = (0, 20, 250, 333, 500, 1000, 2000, 3000, 5000, 10000)
+
+class MagWidget(TQWidget):
+ def __init__(self, tqApp, parent = None, name = None):
+ self.qApp = tqApp
+ TQWidget.__init__(self, parent, name)
+ self.pm = TQPixmap() # pixmap magnified
+ self.p = TQPixmap() # pixmap
+ self.image = TQImage() # image of pixmap (for RGB)
+ self.z = 0 # zoom factor
+ self.r = 0 # autorefresh rate (index into refreshrates)
+ self.grabbing = FALSE # TRUE if currently grabbing
+ self.grabx = -1
+ self.graby = -1
+
+ self.zoom = TQComboBox(FALSE, self)
+ self.zoom.insertStrList(zoomfactors, len(zoomfactors))
+ self.connect(self.zoom, SIGNAL("activated(int)"),
+ self.setZoom)
+
+ self.refresh = TQComboBox(FALSE, self)
+ self.refresh.insertStrList(refreshrates, len(refreshrates))
+ self.connect(self.refresh, SIGNAL("activated(int)"),
+ self.setRefresh)
+
+ x = 0
+ w = 0
+ h = 20
+ for s in zoomfactors:
+ cw = self.zoom.fontMetrics().width(s)
+ w = max(cw, w)
+ self.zoom.setGeometry(x, 2, w + 30, h)
+
+ x = w + 34
+ w = 0
+ for s in refreshrates:
+ cw = self.refresh.fontMetrics().width(s)
+ w = max(cw, w)
+ self.refresh.setGeometry(x, 2, w + 30, h)
+
+ self.saveButton = TQPushButton(self)
+ self.connect(self.saveButton, SIGNAL("clicked()"), self.save)
+ self.saveButton.setText("Save")
+ self.saveButton.setGeometry(x + w + 30 + 2, 2,
+ 10 + self.saveButton.fontMetrics().width("Save"), h)
+
+ self.quitButton = TQPushButton(self)
+ self.connect(self.quitButton, SIGNAL("clicked()"), self.qApp, SLOT("quit()"))
+ self.quitButton.setText("Quit")
+ self.quitButton.setGeometry(self.saveButton.geometry().right() + 2, 2,
+ 10 + self.quitButton.fontMetrics().width("Quit"), h)
+
+ self.rgb = TQLabel(self)
+ self.rgb.setText("")
+ self.rgb.setAlignment(TQt.AlignVCenter)
+ self.rgb.resize(self.width(), self.rgb.fontMetrics().height() + 4)
+
+ self.yoffset = self.zoom.height() + 4 + self.rgb.height()
+ self.setMinimumSize(self.quitButton.geometry().topRight().x() + 2,
+ self.yoffset + 20)
+ w = self.quitButton.geometry().topRight().x() + 2
+ self.resize(w, w)
+
+ self.setMouseTracking(TRUE)
+ self.grabx = self.qApp.desktop().width() / 2
+ self.graby = self.qApp.desktop().height() / 2
+ self.grabAround(TQPoint(self.grabx, self.graby))
+
+ #self.zoom.setCurrentItem(1) # grabAround sets zoom factor
+ #self.setZoom(1)
+ self.refresh.setCurrentItem(5)
+ self.setRefresh(5)
+
+ def setZoom(self, index):
+ if index == 8:
+ self.z = 16
+ else:
+ self.z = index + 1
+ self.grab()
+
+ def setRefresh(self, index):
+ self.r = index
+ self.killTimers()
+ if index and not self.grabbing:
+ #print "st:", timer[index]
+ self.startTimer(timer[index])
+
+ def save(self):
+ if not self.p.isNull():
+ self.killTimers()
+ fn = TQFileDialog.getSaveFileName()
+ if not fn.isEmpty():
+ self.p.save(fn, "BMP")
+ if self.r:
+ self.startTimer(timer[self.r])
+
+ def grab(self):
+ if not self.isVisible() or self.grabx < 0 or self.graby < 0:
+ return
+
+ w = (self.width() + self.z - 1) / self.z
+ h = (self.height() + self.z - 1 - self.yoffset) / self.z
+
+ if w < 1 or h < 1:
+ return
+
+ x = self.grabx - w / 2
+ y = self.graby - h / 2
+
+ if x + w > TQApplication.desktop().width():
+ x = TQApplication.desktop().width() - w
+ elif x < 0:
+ x = 0
+
+ if y + h > TQApplication.desktop().height():
+ y = TQApplication.desktop().height() - h
+ elif y < 0:
+ y = 0
+
+ self.p = TQPixmap.grabWindow(TQApplication.desktop().winId(), x, y, w, h)
+ self.image = self.p.convertToImage()
+ m = TQWMatrix()
+ #print "z:", self.z
+ m.scale(float(self.z), float(self.z))
+ self.pm = self.p.xForm(m)
+ self.repaint(FALSE)
+
+ def paintEvent(self, e):
+ if not self.pm.isNull():
+ paint = TQPainter(self)
+ paint.drawPixmap(0, self.zoom.height() + 4, self.pm,
+ 0, 0, self.width(), self.height() - self.yoffset)
+
+ def mousePressEvent(self, e):
+ if not self.grabbing:
+ self.grabbing = TRUE
+ self.killTimers()
+ self.grabMouse(TQt.crossCursor)
+ self.grabx = -1
+ self.graby = -1
+ else:
+ self.grabx = self.mapToGlobal(e.pos()).x()
+ self.graby = self.mapToGlobal(e.pos()).y()
+
+ def mouseReleaseEvent(self, e):
+ if self.grabbing and self.grabx >= 0 and self.graby >= 0:
+ self.grabbing = FALSE
+ self.grabAround(e.pos())
+ self.releaseMouse()
+
+ def grabAround(self, pos):
+ rx = self.mapToGlobal(pos).x()
+ ry = self.mapToGlobal(pos).y()
+ w = abs(rx - self.grabx)
+ h = abs(ry - self.graby)
+ if w > 10 and h > 10:
+ pz = 1
+ while w*pz*h*pz < self.width()*(self.height()-self.yoffset) and \
+ w*pz < TQApplication.desktop().width() and \
+ h*pz < TQApplication.desktop().height():
+ pz += 1
+ if (w*pz*h*pz - self.width()*(self.height()-self.yoffset)) > \
+ (self.width()*(self.height()-self.yoffset) - w*(pz-1)*h*(pz-1)):
+ pz -= 1
+ if pz < 1:
+ pz = 1
+ elif pz > 8:
+ pz = 8
+ self.zoom.setCurrentItem(pz-1)
+ self.z = pz
+ self.grabx = min(rx, self.grabx) + w / 2
+ self.graby = min(ry, self.graby) + h / 2
+ #self.resize(w*self.z, h*self.z*self.yoffset)
+ self.grab()
+
+ def mouseMoveEvent(self, e):
+ if self.grabbing or self.pm.isNull() or \
+ e.pos().y() > self.height() - self.zoom.fontMetrics().height() - 4 or \
+ e.pos().y() < self.zoom.height() + 4:
+ self.rgb.setText("")
+ else:
+ x = e.pos().x() / self.z
+ y = (e.pos().y() - self.zoom.height() - 4) / self.z
+ pixelinfo = ""
+ if self.image.valid(x, y):
+ px = self.image.pixel(x, y)
+ pixelinfo = "%3d,%3d,%3d #%02x%02x%02x" % (
+ tqRed(px), tqGreen(px), tqBlue(px),
+ tqRed(px), tqGreen(px), tqBlue(px))
+ self.rgb.setText("x=%d, y=%d %s" % \
+ (x + self.grabx, y + self.graby, pixelinfo))
+
+ def focusOutEvent(self, e):
+ self.rgb.setText("")
+
+ def timerEvent(self, e):
+ self.grab()
+
+ def resizeEvent(self, e):
+ self.rgb.setGeometry(0, self.height() - self.rgb.height(),
+ self.width(), self.rgb.height())
+
+if __name__=='__main__':
+ app = TQApplication( sys.argv )
+ m = MagWidget(app)
+ app.setMainWidget(m)
+ m.show()
+ app.exec_loop()
diff --git a/examples/qt.png b/examples/qt.png
new file mode 100644
index 0000000..d63e16f
--- /dev/null
+++ b/examples/qt.png
Binary files differ
diff --git a/examples/qtlogo.png b/examples/qtlogo.png
new file mode 100644
index 0000000..c83c7b2
--- /dev/null
+++ b/examples/qtlogo.png
Binary files differ
diff --git a/examples/rangecontrols.py b/examples/rangecontrols.py
new file mode 100755
index 0000000..14588c8
--- /dev/null
+++ b/examples/rangecontrols.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+"""**************************************************************************
+** $Id: rangecontrols.py,v 1.1 2003/07/01 14:18:37 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+
+INT_MAX = sys.maxsize
+
+class RangeControls( TQVBox ):
+ def __init__( self, parent=None, name=None ):
+ TQVBox.__init__( self, parent, name )
+
+ row1 = TQHBox( self )
+ cell2 = TQVBox( row1 )
+ cell2.setMargin( 10 )
+ cell2.setFrameStyle( TQFrame.WinPanel | TQFrame.Sunken )
+
+ TQWidget( cell2 )
+
+ label1 = TQLabel( TQString( "Enter a value between\n%1 and %2:" ).arg( -INT_MAX ).arg( INT_MAX ), cell2 )
+ label1.setMaximumHeight( label1.sizeHint().height() )
+ sb1 = TQSpinBox( -INT_MAX, INT_MAX, 1, cell2 )
+ sb1.setValue( 0 )
+
+ label2 = TQLabel( "Enter a zoom value:", cell2 )
+ label2.setMaximumHeight( label2.sizeHint().height() )
+ sb2 = TQSpinBox( 0, 1000, 10, cell2 )
+ sb2.setSuffix( " %" )
+ sb2.setSpecialValueText( "Automatic" )
+
+ label3 = TQLabel( "Enter a price:", cell2 )
+ label3.setMaximumHeight( label3.sizeHint().height() )
+ sb3 = TQSpinBox( 0, INT_MAX, 1, cell2 )
+ sb3.setPrefix( "$" )
+ sb3.setValue( 355 )
+
+ TQWidget( cell2 )
+
+ row2 = TQHBox( self )
+
+ cell3 = TQVBox( row2 )
+ cell3.setMargin( 10 )
+ cell3.setFrameStyle( TQFrame.WinPanel | TQFrame.Sunken )
+ hslider = TQSlider( 0, 64, 1, 33, TQt.Horizontal, cell3 )
+ lcd2 = TQLCDNumber( 2, cell3 )
+ lcd2.display( 33 )
+ lcd2.setSegmentStyle( TQLCDNumber.Filled )
+ self.connect( hslider, SIGNAL("valueChanged( int )"), lcd2, SLOT("display( int )") )
+
+ cell4 = TQHBox( row2 )
+ cell4.setFrameStyle( TQFrame.WinPanel | TQFrame.Sunken )
+ cell4.setMargin( 10 )
+ vslider = TQSlider( 0, 64, 1, 8, TQt.Vertical, cell4 )
+ lcd3 = TQLCDNumber( 3, cell4 )
+ lcd3.display( 8 )
+ self.connect( vslider, SIGNAL("valueChanged( int )"), lcd3, SLOT("display( int )") )
+
+def main( args ):
+ a = TQApplication( args )
+
+ rangecontrols = RangeControls()
+ rangecontrols.resize( 500, 300 )
+ rangecontrols.setCaption( "TQt Example - Range Control Widgets" );
+ a.setMainWidget( rangecontrols )
+ rangecontrols.show()
+
+ a.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/richtext.py b/examples/richtext.py
new file mode 100755
index 0000000..2e6abac
--- /dev/null
+++ b/examples/richtext.py
@@ -0,0 +1,136 @@
+#!/usr/bin/env python
+
+"""**************************************************************************
+** $Id: richtext.py,v 1.1 2003/07/01 14:18:37 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+
+sayings = [
+ "<b>Saying 1:</b><br>"
+ "<hr><br><br>"
+ "<big>Evil is that which one believes of others. It is a sin to believe evil "
+ "of others, but it is seldom a mistake.</big><br><br>"
+ "<center><i>-- H.L. Mencken</i></center>",
+
+ "<b>Saying 2:</b><br>"
+ "<hr><br><br>"
+ "<big>A well-used door needs no oil on its hinges.<br>"
+ "A swift-flowing steam does not grow stagnant.<br>"
+ "Neither sound nor thoughts can travel through a vacuum.<br>"
+ "Software rots if not used.<br><br>"
+ "These are great mysteries.</big><br><br>"
+ "<center><i>-- Geoffrey James, \"The Tao of Programming\"</i></center>",
+
+ "<b>Saying 3:</b><br>"
+ "<hr><br><br>"
+ "<big>Show business is just like high school, except you get paid.</big><br><br>"
+ "<center><i>-- Martin Mull</i></center>",
+
+ "<b>Saying 4:</b><br>"
+ "<hr><br><br>"
+ "<big><b>The Least Successful Executions</b><br>"
+ "<twocolumn><p> History has furnished us with two executioners worthy of attention. "
+ "The first performed in Sydney in Australia. In 1803 three attempts were "
+ "made to hang a Mr. Joseph Samuels. On the first two of these the rope "
+ "snapped, while on the third Mr. Samuels just hung there peacefully until he "
+ "and everyone else got bored. Since he had proved unsusceptible to capital "
+ "punishment, he was reprieved.</p>"
+ "<p> The most important British executioner was Mr. James Berry who "
+ "tried three times in 1885 to hang Mr. John Lee at Exeter Jail, but on each "
+ "occasion failed to get the trap door open.<!p>"
+ "<p> In recognition of this achievement, the Home Secretary commuted "
+ "Lee's sentence to \"life\" imprisonment. He was released in 1917, emigrated "
+ "to America and lived until 1933.</p></twocolumn></big><br><br>"
+ "<center><i>-- Stephen Pile, \"The Book of Heroic Failures\"</i></center>",
+
+ "<b>Saying 5:</b><br>"
+ "<hr><br><br>"
+ "<big>If you can, help others. If you can't, at least don't hurt others.</big><br><br>"
+ "<center><i>-- the Dalai Lama</i></center>",
+
+ "<b>Saying 6:</b><br>"
+ "<hr><br><br>"
+ "<big>Television has brought back murder into the home -- where it belongs.</big><br><br>"
+ "<center><i>-- Alfred Hitchcock</i></center>",
+
+ "<b>Saying 7:</b><br>"
+ "<hr><br><br>"
+ "<big>I don't know who my grandfather was; I am much more concerned to know "
+ "what his grandson will be.</big><br><br>"
+ "<center><i>-- Abraham Lincoln</i></center>",
+
+ 0
+]
+
+class MyRichText( TQVBox ):
+ def __init__( self, parent = None, name = None ):
+ TQVBox.__init__( self, parent, name )
+
+ self.setMargin( 5 )
+
+ self.view = TQTextView( self )
+ #self.view.setText( "This is a <b>Test</b> with <i>italic</i> <u>stuff</u>" )
+ paper = TQBrush()
+ paper.setPixmap( TQPixmap( "marble.png" ) )
+ if paper.pixmap() != 0 :
+ self.view.setPaper( paper )
+ else :
+ self.view.setPaper( white )
+
+ self.view.setText( sayings[0] )
+ self.view.setMinimumSize( 450, 250 )
+
+ buttons = TQHBox( self )
+ buttons.setMargin( 5 )
+
+ self.bClose = TQPushButton( "&Close", buttons )
+ self.bPrev = TQPushButton( "<< &Prev", buttons )
+ self.bNext = TQPushButton( "&Next >>", buttons )
+
+ self.bPrev.setEnabled( False )
+
+ self.connect( self.bClose, SIGNAL("clicked()"), tqApp, SLOT("quit()") )
+ self.connect( self.bPrev, SIGNAL("clicked()"), self.prev )
+ self.connect( self.bNext, SIGNAL("clicked()"), self.__next__ )
+
+ self.num = 0
+
+ def prev( self ):
+ if self.num <= 0 :
+ return
+ self.num -= 1
+ self.view.setText( sayings[self.num] )
+ if self.num == 0 :
+ self.bPrev.setEnabled( False )
+ self.bNext.setEnabled( True )
+
+ def __next__( self ):
+ self.num += 1
+ if not sayings[self.num]:
+ return
+ self.view.setText( sayings[self.num] )
+ if not sayings[self.num + 1]:
+ self.bNext.setEnabled( False )
+ self.bPrev.setEnabled( True )
+
+def main( args ):
+ a = TQApplication(sys.argv) # application object
+
+ richtext = MyRichText()
+ richtext.resize( 450, 350 );
+ richtext.setCaption( "TQt Example - Richtext" )
+ a.setMainWidget( richtext )
+ richtext.show()
+
+ a.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/secret.py b/examples/secret.py
new file mode 100644
index 0000000..34560ed
--- /dev/null
+++ b/examples/secret.py
@@ -0,0 +1,65 @@
+# This is part of the dragdrop example.
+
+
+from python_tqt.qt import *
+
+
+def canDecode(e):
+ return e.provides( "secret/magic" )
+
+
+def decode(e):
+ payload = str(e.data( "secret/magic" ))
+ if ( str(payload) != '' ):
+ e.accept()
+ return TQString("The secret number is "+str(ord(payload)) )
+
+ return None
+
+
+class SecretDrag(TQStoredDrag):
+ def __init__(self, secret, parent=None, name=None):
+ TQStoredDrag.__init__(self, 'secret/magic', parent, name)
+ data = TQByteArray(chr(secret))
+ self.setEncodedData( data )
+
+
+# XPM
+picture_xpm = [
+ "16 16 3 1",
+ " c None",
+ ". c #000000",
+ "X c #FFFF00",
+ " ..... ",
+ " ..XXXXX.. ",
+ " .XXXXXXXXX. ",
+ " .XXXXXXXXXXX. ",
+ " .XX..XXX..XX. ",
+ ".XXXXXXXXXXXXX. ",
+ ".XX...XXX...XX. ",
+ ".XXX..XXX..XXX. ",
+ ".XXXXXXXXXXXXX. ",
+ ".XXXXXX.XXXXXX. ",
+ " .XX.XX.XX.XX. ",
+ " .XXX..X..XXX. ",
+ " .XXXXXXXXX. ",
+ " ..XXXXX.. ",
+ " ..... ",
+ " "
+]
+
+
+class SecretSource(TQLabel):
+ def __init__(self, secret, parent=None, name=None):
+ TQLabel.__init__(self, "Secret", parent, name)
+ self.setEraseColor( TQt.blue.light() )
+ self.setFrameStyle( TQLabel.Box | TQLabel.Sunken )
+ self.setMinimumHeight( self.sizeHint().height()*2 )
+ self.setAlignment( TQLabel.AlignCenter )
+ self.mySecret = secret
+
+ def mousePressEvent(self, e):
+ sd = SecretDrag( self.mySecret, self )
+ sd.setPixmap(TQPixmap(picture_xpm),TQPoint(8,8))
+ sd.dragCopy()
+ self.mySecret = self.mySecret + 1
diff --git a/examples/semaphore.py b/examples/semaphore.py
new file mode 100755
index 0000000..79affb2
--- /dev/null
+++ b/examples/semaphore.py
@@ -0,0 +1,203 @@
+#!/usr/bin/env python
+#
+# A port of the semaphore example from TQt.
+
+
+import sys
+
+# Check if thread support was enabled.
+try:
+ from python_tqt.qt import TQThread
+except:
+ print("Thread support not enabled")
+ sys.exit(1)
+
+from python_tqt.qt import *
+
+
+# The semaphore instances.
+yellowSem = None
+greenSem = None
+
+
+class YellowThread(TQThread):
+ def __init__(self,o):
+ TQThread.__init__(self)
+
+ self.receiver = o
+ self.stopped = 0
+ self.mutex = TQMutex()
+
+ def run(self):
+ global yellowSem, greenSem
+
+ for i in range(20):
+ yellowSem += 1
+
+ event = TQCustomEvent(12345)
+ event.setData(TQString("Yellow!"))
+ TQThread.postEvent(self.receiver,event)
+ self.msleep(200);
+
+ greenSem -= 1
+
+ self.mutex.lock()
+ if self.stopped:
+ self.stopped = 0
+ self.mutex.unlock()
+ break
+
+ self.mutex.unlock()
+
+ yellowSem += 1
+
+ event = TQCustomEvent(12346)
+ event.setData(TQString("Yellow!"))
+ TQThread.postEvent(self.receiver,event)
+
+ greenSem -= 1
+
+ def stop(self):
+ self.mutex.lock()
+ self.stopped = 1
+ self.mutex.unlock()
+
+
+class GreenThread(TQThread):
+ def __init__(self,o):
+ TQThread.__init__(self)
+
+ self.receiver = o
+ self.stopped = 0
+ self.mutex = TQMutex()
+
+ def run(self):
+ global yellowSem, greenSem
+
+ for i in range(20):
+ greenSem += 1
+
+ event = TQCustomEvent(12345)
+ event.setData(TQString("Green!"))
+ TQThread.postEvent(self.receiver,event)
+ self.msleep(200)
+
+ yellowSem -= 1
+
+ self.mutex.lock()
+ if self.stopped:
+ self.stopped = 0
+ self.mutex.unlock()
+ break
+
+ self.mutex.unlock()
+
+ greenSem += 1
+
+ event = TQCustomEvent(12346)
+ event.setData(TQString("Green!"))
+ TQThread.postEvent(self.receiver,event)
+ self.msleep(10)
+
+ yellowSem -= 1
+
+ def stop(self):
+ self.mutex.lock()
+ self.stopped = 1
+ self.mutex.unlock()
+
+
+class SemaphoreExample(TQWidget):
+ def __init__(self):
+ TQWidget.__init__(self)
+
+ self.yellowThread = YellowThread(self)
+ self.greenThread = GreenThread(self)
+
+ global yellowSem, greenSem
+ yellowSem = TQSemaphore(1)
+ greenSem = TQSemaphore(1)
+
+ self.button = TQPushButton("&Ignition!",self)
+ self.connect(self.button,SIGNAL("clicked()"),self.startExample)
+
+ self.mlineedit = TQMultiLineEdit(self)
+ self.label = TQLabel(self)
+
+ vbox = TQVBoxLayout(self,5)
+ vbox.addWidget(self.button)
+ vbox.addWidget(self.mlineedit)
+ vbox.addWidget(self.label)
+
+ def __del__(self):
+ stopYellow = self.yellowThread.running()
+ stopGreen = self.greenThread.running()
+
+ if stopYellow:
+ self.yellowThread.stop()
+
+ if self.greenThread.running():
+ self.greenThread.stop()
+
+ if stopYellow:
+ self.yellowThread.wait()
+
+ if stopGreen:
+ self.greenThread.wait()
+
+ global yellowSem, greenSem
+ yellowSem = None
+ greenSem = None
+
+ def startExample(self):
+ if self.yellowThread.running() or self.greenThread.running():
+ TQMessageBox.information(self,"Sorry",
+ "The threads have not completed yet, and must finish before "
+ "they can be started again.")
+
+ return
+
+ self.mlineedit.clear()
+
+ global yellowSem
+
+ while yellowSem.available() < yellowSem.total():
+ yellowSem -= 1
+
+ yellowSem += 1
+
+ self.yellowThread.start()
+ self.greenThread.start()
+
+ def customEvent(self,event):
+ if event.type() == 12345:
+ s = event.data()
+
+ self.mlineedit.append(s)
+
+ if s.latin1() == "Green!":
+ self.label.setEraseColor(TQt.green)
+ else:
+ self.label.setEraseColor(TQt.yellow)
+
+ self.label.setText(s)
+
+ del s
+ elif event.type() == 12346:
+ s = event.data()
+
+ TQMessageBox.information(self,s.latin1() + " - Finished",
+ "The thread creating the \"" + s.latin1() +
+ "\" events has finished.")
+
+ del s
+ else:
+ print("Unknown custom event type:", event.type())
+
+
+app = TQApplication(sys.argv)
+se = SemaphoreExample()
+app.setMainWidget(se)
+se.show()
+
+sys.exit(app.exec_loop())
diff --git a/examples/smalltable.py b/examples/smalltable.py
new file mode 100755
index 0000000..52f212a
--- /dev/null
+++ b/examples/smalltable.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: smalltable.py,v 1.1 2002/06/19 07:56:07 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+import os
+from python_tqt.qt import *
+from python_tqt.qttable import *
+
+TRUE = 1
+FALSE = 0
+
+numRows = 30
+numCols = 10
+
+if __name__ == '__main__':
+ app = TQApplication(sys.argv)
+
+ table = TQTable(numRows, numCols)
+
+ header = table.horizontalHeader()
+
+ header.setLabel(0, "Tiny", 40)
+ header.setLabel(1, "Checkboxes")
+ header.setLabel(5, "Combos")
+ header.setMovingEnabled(TRUE)
+
+ img = TQImage("trolltech.bmp")
+ pix = TQPixmap(img.scaleHeight(table.rowHeight(3)))
+ table.setPixmap(3, 2, pix)
+ table.setText(3, 2, "A Pixmap")
+
+ comboEntries = TQStringList("one")
+ comboEntries.append("two")
+ comboEntries.append("three")
+ comboEntries.append("four")
+
+ for i in range(numRows):
+ item = TQComboTableItem(table, comboEntries, FALSE)
+ item.setCurrentItem(i % 4)
+ table.setItem(i, 5, item)
+
+ for i in range(numRows):
+ table.setItem(i, 1, TQCheckTableItem(table, "Check me"))
+
+ table.setCaption("Small table example")
+ table.show()
+ app.setMainWidget(table)
+ app.exec_loop()
diff --git a/examples/splitter.py b/examples/splitter.py
new file mode 100755
index 0000000..a220d08
--- /dev/null
+++ b/examples/splitter.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+
+class Test(TQWidget):
+ def __init__(self, parent=None, name='Test', f=0):
+ TQWidget.__init__(self, parent, name, f)
+
+ def paintEvent(self, e):
+ p = TQPainter(self)
+ p.setClipRect(e.rect())
+ d = 1000
+ x1 = 0
+ x2 = self.width() - 1
+ y1 = 0
+ y2 = self.height() - 1
+
+ x = int((x1+x2)/2)
+ p.drawLine(x, y1, x+d, y1+d)
+ p.drawLine(x, y1, x-d, y1+d)
+ p.drawLine(x, y2, x+d, y2-d)
+ p.drawLine(x, y2, x-d, y2-d)
+
+ y = int((y1+y2)/2)
+ p.drawLine(x1, y, x1+d, y+d)
+ p.drawLine(x1, y, x1+d, y-d)
+ p.drawLine(x2, y, x2-d, y+d)
+ p.drawLine(x2, y, x2-d, y-d)
+
+
+if __name__=="__main__":
+ a = TQApplication(sys.argv)
+
+ s1 = TQSplitter(TQt.Vertical, None, "main")
+ s2 = TQSplitter(TQt.Horizontal, s1, "top")
+
+ t1 = Test(s2)
+ t1.setEraseColor(TQt.blue.light(180))
+ t1.setMinimumSize(50,0)
+
+ t2 = Test(s2)
+ t2.setEraseColor(TQt.green.light(180))
+ s2.setResizeMode(t2, TQSplitter.KeepSize)
+ s2.moveToFirst(t2)
+
+ s3 = TQSplitter(TQt.Horizontal, s1, "bottom")
+
+ t3 = Test(s3)
+ t3.setEraseColor(TQt.red)
+ t4 = Test(s3)
+ t4.setEraseColor(TQt.white)
+
+ t5 = Test(s3)
+ t5.setMaximumHeight(250)
+ t5.setMinimumSize(80,50)
+ t5.setEraseColor(TQt.yellow)
+
+ s1.setOpaqueResize(1)
+ s2.setOpaqueResize(1)
+ s3.setOpaqueResize(1)
+
+ a.setMainWidget(s1)
+ s1.show()
+ a.exec_loop()
diff --git a/examples/tabdialog.py b/examples/tabdialog.py
new file mode 100755
index 0000000..00e66f6
--- /dev/null
+++ b/examples/tabdialog.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+
+"""**************************************************************************
+** $Id: tabdialog.py,v 1.1 2003/07/01 14:18:37 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+
+class TabDialog( TQTabDialog ):
+ def __init__( self, parent=None, name=None, filename=None ):
+ TQTabDialog.__init__( self, parent, name )
+ self.filename = TQString( filename )
+ self.fileinfo = TQFileInfo( filename )
+ self.setupTab1()
+ self.setupTab2()
+ self.setupTab3()
+ self.connect( self, SIGNAL("applyButtonPressed()"), tqApp, SLOT("quit()" ) )
+
+ def setupTab1( self ):
+ tab1 = TQVBox( self )
+ tab1.setMargin( 5 )
+
+ TQLabel( "Filename:", tab1 )
+ fname = TQLineEdit( self.filename, tab1 )
+ fname.setFocus()
+
+ TQLabel( "Path:", tab1 )
+ path = TQLabel( self.fileinfo.dirPath( True ), tab1 )
+ path.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
+
+ TQLabel( "Size:", tab1 )
+ size = TQLabel( TQString( "%1 KB" ).arg( self.fileinfo.size() ), tab1 )
+ size.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
+
+ TQLabel( "Last Read:", tab1 )
+ lread = TQLabel( self.fileinfo.lastRead().toString(), tab1 )
+ lread.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
+
+ TQLabel( "Last Modified:", tab1 )
+ lmodif = TQLabel( self.fileinfo.lastModified().toString(), tab1 )
+ lmodif.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
+
+ self.addTab( tab1, "General" )
+
+ def setupTab2( self ):
+ tab2 = TQVBox( self )
+ tab2.setMargin( 5 )
+
+ bg = TQButtonGroup( 1, TQGroupBox.Horizontal, "Permissions", tab2 )
+
+ readable = TQCheckBox( "Readable", bg )
+ if self.fileinfo.isReadable() :
+ readable.setChecked( True )
+
+ writable = TQCheckBox( "Writeable", bg )
+ if self.fileinfo.isWritable() :
+ writable.setChecked( True )
+
+ executable = TQCheckBox( "Executable", bg )
+ if self.fileinfo.isExecutable() :
+ executable.setChecked( True )
+
+ bg2 = TQButtonGroup( 2, TQGroupBox.Horizontal, "Owner", tab2 )
+
+ TQLabel( "Owner", bg2 )
+ owner = TQLabel( self.fileinfo.owner(), bg2 )
+ owner.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
+
+ TQLabel( "Group", bg2 )
+ group = TQLabel( self.fileinfo.group(), bg2 )
+ group.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
+
+ self.addTab( tab2, "Permissions" )
+
+ def setupTab3( self ):
+ tab3 = TQVBox( self )
+ tab3.setMargin( 5 )
+ tab3.setSpacing( 5 )
+
+ TQLabel( TQString( "Open %1 with:" ).arg( self.filename ), tab3 )
+
+ prgs = TQListBox( tab3 )
+ for i in range( 0, 30, 1 ) :
+ prg = TQString( "Application %1" ).arg( i )
+ prgs.insertItem( prg )
+ prgs.setCurrentItem( 3 )
+
+ TQCheckBox( TQString( "Open files with the extension '%1' always with this application" ).arg( self.fileinfo.extension() ), tab3 )
+
+ self.addTab( tab3, "Applications" )
+
+def main( args ):
+ a = TQApplication(sys.argv)
+ #sys.argv.append("tabdialog.py") # to test uncomment this line
+ if len(sys.argv) < 2:
+ filename = TQString(".")
+ else:
+ filename = TQString(sys.argv[1])
+
+ tabdialog = TabDialog( None, "tabdialog", filename )
+ tabdialog.resize( 450, 350 );
+ tabdialog.setCaption( "TQt Example - Tabbed Dialog" )
+ a.setMainWidget( tabdialog )
+ tabdialog.show()
+
+ a.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/tablestatistics.py b/examples/tablestatistics.py
new file mode 100755
index 0000000..d6b6b2e
--- /dev/null
+++ b/examples/tablestatistics.py
@@ -0,0 +1,170 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: tablestatistics.py,v 1.1 2002/06/19 07:56:07 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+import os
+from python_tqt.qt import *
+from python_tqt.qttable import *
+
+TRUE = 1
+FALSE = 0
+
+# column constants
+TB_FILE = 0
+TB_SIZE = 1
+TB_FLAG = 2
+TB_COLS = 3
+
+dirs = (
+ "kernel",
+ "tools",
+ "widgets",
+ "dialogs",
+ "xml",
+ "table",
+ "network",
+ "opengl",
+ "canvas",
+)
+
+class Table(TQTable):
+ def __init__(self):
+ TQTable.__init__(self, 0, TB_COLS)
+ self.setSorting(TRUE)
+ self.horizontalHeader().setLabel(TB_FILE, self.tr("File"))
+ self.horizontalHeader().setLabel(TB_SIZE, self.tr("Size (bytes)"))
+ self.horizontalHeader().setLabel(TB_FLAG, self.tr("Use in Sum"))
+ self.initTable()
+ self.adjustColumn(TB_FILE)
+
+ # if the user edited something we might need to recalculate the sum
+ self.connect(self, SIGNAL("valueChanged(int, int)"), self.recalcSum)
+
+ def initTable(self):
+ # read all the TQt source and header files into a list
+ all = []
+ qtdir = os.getenv("TQTDIR")
+ if qtdir is None:
+ raise Exception("The TQTDIR environment variable has not been set.")
+ for i in dirs:
+ dir = TQDir(os.path.join(qtdir, "src", i))
+ lst = TQStringList(dir.entryList("*.cpp; *.h"))
+ for f in lst:
+ if f.contains("moc"):
+ continue
+ all.append(os.path.join(i, str(f)))
+
+ # set the number of rows we'll need for the table
+ self.setNumRows(len(all) + 1)
+
+ i = 0
+ sum = 0
+ # insert the data into the table
+ for it in all:
+ self.setText(i, TB_FILE, it)
+ f = TQFile(os.path.join(qtdir, "src", str(it)))
+ self.setText(i, TB_SIZE, str(f.size()))
+ ci = ComboItem(self, TQTableItem.WhenCurrent)
+ self.setItem(i, TB_FLAG, ci)
+ i = i + 1
+ sum += f.size()
+ self.displaySum(sum)
+
+ def recalcSum(self, dummy, col):
+ # only recalc if a value in the second or third column changed
+ if col < TB_SIZE or col > TB_FLAG:
+ return
+
+ sum = 0
+ for i in range(self.numRows()-1):
+ if str(self.text(i, TB_FLAG)) == "No":
+ continue
+ sum += int(str(self.text(i, TB_SIZE)))
+ self.displaySum(sum)
+
+ def displaySum(self, sum):
+ # insert calculated data
+ i1 = TableItem(self, TQTableItem.Never, self.tr("Sum"))
+ self.setItem(self.numRows()-1, TB_FILE, i1)
+ i2 = TableItem(self, TQTableItem.Never, str(sum))
+ self.setItem(self.numRows()-1, TB_SIZE, i2)
+
+ def sortColumn(self, col, ascending, wholeRows):
+ # sum row should not be sorted, so get rid of it for now
+ self.clearCell(self.numRows()-1, TB_FILE)
+ self.clearCell(self.numRows()-1, TB_SIZE)
+ # do sort
+ TQTable.sortColumn(self, col, ascending, TRUE)
+ # re-insert sum row
+ self.recalcSum(0, TB_SIZE)
+
+
+class TableItem(TQTableItem):
+ def __init__(self, *args):
+ TQTableItem.__init__(*(self,) + args)
+
+ def paint(self, p, cg, cr, selected):
+ g = TQColorGroup(cg)
+ # last row is the sum row - we want to make it more visible by
+ # using a red background
+ if self.row() == self.table().numRows()-1:
+ g.setColor(TQColorGroup.Base, TQColor("red"))
+ TQTableItem.paint(self, p, g, cr, selected)
+
+
+class ComboItem(TQTableItem):
+ def __init__(self, t, et):
+ TQTableItem.__init__(self, t, et, "Yes")
+ self.cb = None
+ # we do not want this item to be replaced
+ self.setReplaceable(FALSE)
+
+ def createEditor(self):
+ # create an editor - a combobox in our case
+ self.cb = TQComboBox(self.table().viewport())
+ TQObject.connect(self.cb, SIGNAL("activated(int)"),
+ self.table(), SLOT("doValueChanged()"))
+ self.cb.insertItem("Yes")
+ self.cb.insertItem("No")
+ # and initialize it
+ if str(self.text()) == "No":
+ self.cb.setCurrentItem(1)
+ else:
+ self.cb.setCurrentItem(0)
+ return self.cb
+
+ def setContentFromEditor(self, w):
+ # the user changed the value of the combobox, so synchronize the
+ # value of the item (its text), with the value of the combobox
+ if w.inherits("TQComboBox"):
+ self.setText(w.currentText())
+ else:
+ TQTableItem.setContentFromEditor(self, w)
+
+ def setText(self, s):
+ # initialize the combobox from the text
+ if self.cb:
+ if str(s) == "No":
+ self.cb.setCurrentItem(1)
+ else:
+ self.cb.setCurrentItem(0)
+ TQTableItem.setText(self, s)
+
+
+if __name__ == '__main__':
+ app = TQApplication(sys.argv)
+
+ t = Table()
+ t.setCaption("Statistics")
+ t.show()
+ app.setMainWidget(t)
+ app.exec_loop()
diff --git a/examples/tooltip.py b/examples/tooltip.py
new file mode 100755
index 0000000..13025e3
--- /dev/null
+++ b/examples/tooltip.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+
+"""**************************************************************************
+** $Id: tooltip.py,v 1.1 2003/07/01 14:18:37 phil Exp $
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+***************************************************************************"""
+
+import sys
+from python_tqt.qt import *
+from random import random
+
+class DynamicTip( TQToolTip ):
+ def __init__( self, parent ):
+ TQToolTip.__init__( self, parent )
+
+ def maybeTip( self, pos ):
+ #if not self.parent.inherits( "TellMe" ):
+ if TQToolTip(self).parentWidget().inherits( "TellMe" ) :
+ return
+ r = TQRect( TQToolTip(self).parentWidget().tip(pos) )
+ if not r.isValid():
+ return
+
+ s = TQString( "position: %d,%d" % (r.center().x(), r.center().y()) )
+ TQToolTip(self).tip( r, s )
+
+
+class TellMe( TQWidget ):
+ def __init__( self, parent=None, name=None ):
+ TQWidget.__init__( self, parent, name )
+
+ self.setMinimumSize( 30, 30 )
+ self.r1 = self.randomRect()
+ self.r2 = self.randomRect()
+ self.r3 = self.randomRect()
+
+ self.t = DynamicTip( self )
+
+ TQToolTip.add( self, self.r3, "this color is called red" ) # <- helpful
+
+ def paintEvent( self, e ):
+
+ p = TQPainter( self )
+
+ # I try to be efficient here, and repaint only what's needed
+ if e.rect().intersects( self.r1 ):
+ p.setBrush( TQt.blue )
+ p.drawRect( self.r1 )
+
+ if e.rect().intersects( self.r2 ):
+ p.setBrush( TQt.blue )
+ p.drawRect( self.r2 )
+
+ if e.rect().intersects( self.r3 ):
+ p.setBrush( TQt.red )
+ p.drawRect( self.r3 )
+
+ def mousePressEvent( self, e ):
+
+ if self.r1.contains( e.pos() ):
+ self.r1 = self.randomRect()
+ if self.r2.contains( e.pos() ):
+ self.r2 = self.randomRect()
+ self.repaint()
+
+ def resizeEvent( self, e ):
+
+ if not self.rect().contains( self.r1 ):
+ self.r1 = self.randomRect()
+ if not self.rect().contains( self.r2 ):
+ self.r2 = self.randomRect()
+
+ def randomRect( self ):
+ return TQRect( int(random() * (self.width() - 20)), int(random() * (self.height() - 20)), 20, 20 )
+
+ def tip( self, p ):
+
+ if self.r1.contains( p ):
+ return self.r1
+ elif self.r2.contains( p ):
+ return self.r2
+ else:
+ return TQRect( 0,0, -1,-1 )
+
+ def __del__( self ):
+ del self.t
+ self.t = None
+
+def main( args ):
+ a = TQApplication( args )
+
+ mw = TellMe()
+ mw.setCaption( "TQt Example - Dynamic Tool Tips" )
+ a.setMainWidget( mw )
+ mw.show()
+
+ a.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/examples/trolltech.bmp b/examples/trolltech.bmp
new file mode 100644
index 0000000..9f399c7
--- /dev/null
+++ b/examples/trolltech.bmp
Binary files differ
diff --git a/examples/trolltech.gif b/examples/trolltech.gif
new file mode 100644
index 0000000..f674369
--- /dev/null
+++ b/examples/trolltech.gif
Binary files differ
diff --git a/examples/tt-logo.png b/examples/tt-logo.png
new file mode 100644
index 0000000..1b0e865
--- /dev/null
+++ b/examples/tt-logo.png
Binary files differ
diff --git a/examples/tut1.py b/examples/tut1.py
new file mode 100755
index 0000000..3e30fcc
--- /dev/null
+++ b/examples/tut1.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+# TQt tutorial 1.
+
+import sys
+from python_tqt import qt
+
+
+a = qt.TQApplication(sys.argv)
+
+hello = qt.TQPushButton("Hello world!", None)
+hello.resize(100, 30)
+
+a.setMainWidget(hello)
+hello.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut10.py b/examples/tut10.py
new file mode 100755
index 0000000..b16804e
--- /dev/null
+++ b/examples/tut10.py
@@ -0,0 +1,145 @@
+#!/usr/bin/env python
+
+# TQt tutorial 10.
+
+import sys
+from python_tqt import qt
+
+
+class LCDRange(qt.TQVBox):
+ def __init__(self, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+ self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ self.slider.setRange(0, 99)
+ self.slider.setValue(0)
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.PYSIGNAL("valueChanged(int)"))
+
+ self.setFocusProxy(self.slider)
+
+ def value(self):
+ return self.slider.value()
+
+ def setValue(self, value):
+ self.slider.setValue(value)
+
+ def setRange(self, minVal, maxVal):
+ if minVal < 0 or maxVal > 99 or minVal > maxVal:
+ raise ValueError("LCDRange.setRange(): invalid range")
+ self.slider.setRange(minVal, maxVal)
+
+
+class CannonField(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ self.ang = 45
+ self.f = 0
+ self.setPalette(qt.TQPalette(qt.TQColor(250, 250, 200)))
+
+ def angle(self):
+ return self.ang
+
+ def setAngle(self, degrees):
+ if degrees < 5:
+ degrees = 5
+ if degrees > 70:
+ degrees = 70
+ if self.ang == degrees:
+ return
+ self.ang = degrees
+ self.repaint(self.cannonRect(), 0)
+ self.emit(qt.PYSIGNAL("angleChanged(int)"), (self.ang, ))
+
+ def force(self):
+ return self.f
+
+ def setForce(self, newton):
+ if newton < 0:
+ newton = 0
+ if self.f == newton:
+ return
+ self.f = newton
+ self.emit(qt.PYSIGNAL("forceChanged(int)"), (self.f, ))
+
+ def paintEvent(self, ev):
+ if not ev.rect().intersects(self.cannonRect()):
+ return
+
+ cr = self.cannonRect()
+ pix = qt.TQPixmap(cr.size())
+ pix.fill(self, cr.topLeft())
+
+ p = qt.TQPainter(pix)
+
+ p.setBrush(qt.TQt.blue)
+ p.setPen(qt.TQt.NoPen)
+
+ p.translate(0, pix.height() - 1)
+ p.drawPie(qt.TQRect(-35, -35, 70, 70), 0, 90 * 16)
+ p.rotate(-self.ang)
+ p.drawRect(qt.TQRect(33, -4, 15, 8))
+ p.end()
+
+ p.begin(self)
+ p.drawPixmap(cr.topLeft(), pix)
+
+ def cannonRect(self):
+ r = qt.TQRect(0, 0, 50, 50)
+ r.moveBottomLeft(self.rect().bottomLeft())
+ return r
+
+ def sizePolicy(self):
+ return qt.TQSizePolicy(qt.TQSizePolicy.Expanding, qt.TQSizePolicy.Expanding)
+
+
+class MyWidget(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("&Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ self.angle = LCDRange(self, "angle")
+ self.angle.setRange(5, 70)
+
+ self.force = LCDRange(self, "force")
+ self.force.setRange(10, 50)
+
+ self.cannonField = CannonField(self, "cannonField")
+
+ self.connect(self.angle, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setAngle)
+ self.connect(self.cannonField, qt.PYSIGNAL("angleChanged(int)"), self.angle.setValue)
+
+ self.connect(self.force, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setForce)
+ self.connect(self.cannonField, qt.PYSIGNAL("forceChanged(int)"), self.force.setValue)
+
+ grid = qt.TQGridLayout(self, 2, 2, 10)
+
+ grid.addWidget(quit, 0, 0)
+ grid.addWidget(self.cannonField, 1, 1)
+ grid.setColStretch(1, 10)
+
+ leftBox = qt.TQVBoxLayout()
+
+ grid.addLayout(leftBox, 1, 0)
+
+ leftBox.addWidget(self.angle)
+ leftBox.addWidget(self.force)
+
+ self.angle.setValue(60)
+ self.force.setValue(25)
+ self.angle.setFocus()
+
+
+qt.TQApplication.setColorSpec(qt.TQApplication.CustomColor)
+a = qt.TQApplication(sys.argv)
+
+w = MyWidget()
+w.setGeometry(100, 100, 500, 355)
+a.setMainWidget(w)
+w.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut11.py b/examples/tut11.py
new file mode 100755
index 0000000..cb6444b
--- /dev/null
+++ b/examples/tut11.py
@@ -0,0 +1,213 @@
+#!/usr/bin/env python
+
+# TQt tutorial 11.
+
+import sys
+import math
+from python_tqt import qt
+
+
+class LCDRange(qt.TQVBox):
+ def __init__(self, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+ self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ self.slider.setRange(0, 99)
+ self.slider.setValue(0)
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.PYSIGNAL("valueChanged(int)"))
+
+ self.setFocusProxy(self.slider)
+
+ def value(self):
+ return self.slider.value()
+
+ def setValue(self, value):
+ self.slider.setValue(value)
+
+ def setRange(self, minVal, maxVal):
+ if minVal < 0 or maxVal > 99 or minVal > maxVal:
+ raise ValueError("LCDRange.setRange(): invalid range")
+ self.slider.setRange(minVal, maxVal)
+
+
+class CannonField(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ self.ang = 45
+ self.f = 0
+ self.timerCount = 0
+
+ self.autoShootTimer = qt.TQTimer(self, "movement handler")
+ self.connect(self.autoShootTimer, qt.SIGNAL("timeout()"), self.moveShot)
+
+ self.shoot_ang = 0
+ self.shoot_f = 0
+
+ self.setPalette(qt.TQPalette(qt.TQColor(250, 250, 200)))
+
+ self.barrelRect = qt.TQRect(33, -4, 15, 8)
+
+ def angle(self):
+ return self.ang
+
+ def setAngle(self, degrees):
+ if degrees < 5:
+ degrees = 5
+ if degrees > 70:
+ degrees = 70
+ if self.ang == degrees:
+ return
+ self.ang = degrees
+ self.repaint(self.cannonRect(), 0)
+ self.emit(qt.PYSIGNAL("angleChanged(int)"), (self.ang, ))
+
+ def force(self):
+ return self.f
+
+ def setForce(self, newton):
+ if newton < 0:
+ newton = 0
+ if self.f == newton:
+ return
+ self.f = newton
+ self.emit(qt.PYSIGNAL("forceChanged(int)"), (self.f, ))
+
+ def shoot(self):
+ if self.autoShootTimer.isActive():
+ return
+
+ self.timerCount = 0
+ self.shoot_ang = self.ang
+ self.shoot_f = self.f
+ self.autoShootTimer.start(50)
+
+ def moveShot(self):
+ r = qt.TQRegion(self.shotRect())
+ self.timerCount = self.timerCount + 1
+
+ shotR = self.shotRect()
+
+ if shotR.x() > self.width() or shotR.y() > self.height():
+ self.autoShootTimer.stop()
+ else:
+ r = r.unite(qt.TQRegion(shotR))
+
+ self.repaint(r)
+
+ def paintEvent(self, ev):
+ updateR = ev.rect()
+ p = qt.TQPainter(self)
+
+ if updateR.intersects(self.cannonRect()):
+ self.paintCannon(p)
+
+ if self.autoShootTimer.isActive() and updateR.intersects(self.shotRect()):
+ self.paintShot(p)
+
+ def paintShot(self, p):
+ p.setBrush(qt.TQt.black)
+ p.setPen(qt.TQt.NoPen)
+ p.drawRect(self.shotRect())
+
+ def paintCannon(self, p):
+ cr = self.cannonRect()
+ pix = qt.TQPixmap(cr.size())
+ pix.fill(self, cr.topLeft())
+
+ tmp = qt.TQPainter(pix)
+ tmp.setBrush(qt.TQt.blue)
+ tmp.setPen(qt.TQt.NoPen)
+
+ tmp.translate(0, pix.height() - 1)
+ tmp.drawPie(qt.TQRect(-35, -35, 70, 70), 0, 90 * 16)
+ tmp.rotate(-self.ang)
+ tmp.drawRect(self.barrelRect)
+ tmp.end()
+
+ p.drawPixmap(cr.topLeft(), pix)
+
+ def cannonRect(self):
+ r = qt.TQRect(0, 0, 50, 50)
+ r.moveBottomLeft(self.rect().bottomLeft())
+ return r
+
+ def shotRect(self):
+ gravity = 4.0
+
+ time = self.timerCount / 4.0
+ velocity = self.shoot_f
+ radians = self.shoot_ang * 3.14159265 / 180
+
+ velx = velocity * math.cos(radians)
+ vely = velocity * math.sin(radians)
+ x0 = (self.barrelRect.right() + 5) * math.cos(radians)
+ y0 = (self.barrelRect.right() + 5) * math.sin(radians)
+ x = x0 + velx * time
+ y = y0 + vely * time - 0.5 * gravity * time * time
+
+ r = qt.TQRect(0, 0, 6, 6)
+ r.moveCenter(qt.TQPoint(int(x), int(self.height() - 1 - y)))
+ return r
+
+ def sizePolicy(self):
+ return qt.TQSizePolicy(qt.TQSizePolicy.Expanding, qt.TQSizePolicy.Expanding)
+
+
+class MyWidget(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("&Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ self.angle = LCDRange(self, "angle")
+ self.angle.setRange(5, 70)
+
+ self.force = LCDRange(self, "force")
+ self.force.setRange(10, 50)
+
+ self.cannonField = CannonField(self, "cannonField")
+
+ self.connect(self.angle, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setAngle)
+ self.connect(self.cannonField, qt.PYSIGNAL("angleChanged(int)"), self.angle.setValue)
+
+ self.connect(self.force, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setForce)
+ self.connect(self.cannonField, qt.PYSIGNAL("forceChanged(int)"), self.force.setValue)
+
+ shoot = qt.TQPushButton("&Shoot", self, "shoot")
+ shoot.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(shoot, qt.SIGNAL("clicked()"), self.cannonField.shoot)
+
+ grid = qt.TQGridLayout(self, 2, 2, 10)
+
+ grid.addWidget(quit, 0, 0)
+ grid.addWidget(self.cannonField, 1, 1)
+ grid.setColStretch(1, 10)
+
+ leftBox = qt.TQVBoxLayout()
+ grid.addLayout(leftBox, 1, 0)
+ leftBox.addWidget(self.angle)
+ leftBox.addWidget(self.force)
+
+ topBox = qt.TQHBoxLayout()
+ grid.addLayout(topBox, 0, 1)
+ topBox.addWidget(shoot)
+ topBox.addStretch(1)
+
+ self.angle.setValue(60)
+ self.force.setValue(25)
+ self.angle.setFocus()
+
+
+qt.TQApplication.setColorSpec(qt.TQApplication.CustomColor)
+a = qt.TQApplication(sys.argv)
+
+w = MyWidget()
+w.setGeometry(100, 100, 500, 355)
+a.setMainWidget(w)
+w.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut12.py b/examples/tut12.py
new file mode 100755
index 0000000..452d1ac
--- /dev/null
+++ b/examples/tut12.py
@@ -0,0 +1,253 @@
+#!/usr/bin/env python
+
+# TQt tutorial 12.
+
+import sys
+import math
+import random
+from python_tqt import qt
+
+
+class LCDRange(qt.TQVBox):
+ def __init__(self, s=None, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+ self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ self.slider.setRange(0, 99)
+ self.slider.setValue(0)
+
+ self.label = qt.TQLabel(" ", self, "label")
+ self.label.setAlignment(qt.TQt.AlignCenter)
+
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.PYSIGNAL("valueChanged(int)"))
+
+ self.setFocusProxy(self.slider)
+
+ if s is not None:
+ self.setText(s)
+
+ def value(self):
+ return self.slider.value()
+
+ def setValue(self, value):
+ self.slider.setValue(value)
+
+ def setRange(self, minVal, maxVal):
+ if minVal < 0 or maxVal > 99 or minVal > maxVal:
+ raise ValueError("LCDRange.setRange(): invalid range")
+
+ self.slider.setRange(minVal, maxVal)
+
+ def text(self):
+ return self.label.text()
+
+ def setText(self, s):
+ self.label.setText(s)
+
+
+class CannonField(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ self.ang = 45
+ self.f = 0
+ self.timerCount = 0
+
+ self.autoShootTimer = qt.TQTimer(self, "movement handler")
+ self.connect(self.autoShootTimer, qt.SIGNAL("timeout()"), self.moveShot)
+
+ self.shoot_ang = 0
+ self.shoot_f = 0
+ self.target = qt.TQPoint(0, 0)
+
+ self.setPalette(qt.TQPalette(qt.TQColor(250, 250, 200)))
+
+ self.barrelRect = qt.TQRect(33, -4, 15, 8)
+
+ self.newTarget()
+
+ def angle(self):
+ return self.ang
+
+ def setAngle(self, degrees):
+ if degrees < 5:
+ degrees = 5
+ if degrees > 70:
+ degrees = 70
+ if self.ang == degrees:
+ return
+ self.ang = degrees
+ self.repaint(self.cannonRect(), 0)
+ self.emit(qt.PYSIGNAL("angleChanged(int)"), (self.ang, ))
+
+ def force(self):
+ return self.f
+
+ def setForce(self, newton):
+ if newton < 0:
+ newton = 0
+ if self.f == newton:
+ return
+ self.f = newton
+ self.emit(qt.PYSIGNAL("forceChanged(int)"), (self.f, ))
+
+ def shoot(self):
+ if self.autoShootTimer.isActive():
+ return
+
+ self.timerCount = 0
+ self.shoot_ang = self.ang
+ self.shoot_f = self.f
+ self.autoShootTimer.start(50)
+
+ def newTarget(self):
+ r = qt.TQRegion(self.targetRect())
+ self.target = qt.TQPoint(random.randint(200, 390), random.randint(10, 265))
+ self.repaint(r.unite(qt.TQRegion(self.targetRect())))
+
+ def moveShot(self):
+ r = qt.TQRegion(self.shotRect())
+ self.timerCount = self.timerCount + 1
+
+ shotR = self.shotRect()
+
+ if shotR.intersects(self.targetRect()):
+ self.autoShootTimer.stop()
+ self.emit(qt.PYSIGNAL("hit()"), ())
+ elif shotR.x() > self.width() or shotR.y() > self.height():
+ self.autoShootTimer.stop()
+ self.emit(qt.PYSIGNAL("missed()"), ())
+ else:
+ r = r.unite(qt.TQRegion(shotR))
+
+ self.repaint(r)
+
+ def paintEvent(self, ev):
+ updateR = ev.rect()
+ p = qt.TQPainter(self)
+
+ if updateR.intersects(self.cannonRect()):
+ self.paintCannon(p)
+
+ if self.autoShootTimer.isActive() and updateR.intersects(self.shotRect()):
+ self.paintShot(p)
+
+ if updateR.intersects(self.targetRect()):
+ self.paintTarget(p)
+
+ def paintShot(self, p):
+ p.setBrush(qt.TQt.black)
+ p.setPen(qt.TQt.NoPen)
+ p.drawRect(self.shotRect())
+
+ def paintTarget(self, p):
+ p.setBrush(qt.TQt.red)
+ p.setPen(qt.TQt.black)
+ p.drawRect(self.targetRect())
+
+ def paintCannon(self, p):
+ cr = self.cannonRect()
+ pix = qt.TQPixmap(cr.size())
+ pix.fill(self, cr.topLeft())
+
+ tmp = qt.TQPainter(pix)
+ tmp.setBrush(qt.TQt.blue)
+ tmp.setPen(qt.TQt.NoPen)
+
+ tmp.translate(0, pix.height() - 1)
+ tmp.drawPie(qt.TQRect(-35, -35, 70, 70), 0, 90 * 16)
+ tmp.rotate(-self.ang)
+ tmp.drawRect(self.barrelRect)
+ tmp.end()
+
+ p.drawPixmap(cr.topLeft(), pix)
+
+ def cannonRect(self):
+ r = qt.TQRect(0, 0, 50, 50)
+ r.moveBottomLeft(self.rect().bottomLeft())
+ return r
+
+ def shotRect(self):
+ gravity = 4.0
+
+ time = self.timerCount / 4.0
+ velocity = self.shoot_f
+ radians = self.shoot_ang * 3.14159265 / 180
+
+ velx = velocity * math.cos(radians)
+ vely = velocity * math.sin(radians)
+ x0 = (self.barrelRect.right() + 5) * math.cos(radians)
+ y0 = (self.barrelRect.right() + 5) * math.sin(radians)
+ x = x0 + velx * time
+ y = y0 + vely * time - 0.5 * gravity * time * time
+
+ r = qt.TQRect(0, 0, 6, 6)
+ r.moveCenter(qt.TQPoint(int(x), int(self.height() - 1 - y)))
+ return r
+
+ def targetRect(self):
+ r = qt.TQRect(0, 0, 20, 10)
+ r.moveCenter(qt.TQPoint(self.target.x(), self.height() - 1 - self.target.y()))
+ return r
+
+ def sizePolicy(self):
+ return qt.TQSizePolicy(qt.TQSizePolicy.Expanding, qt.TQSizePolicy.Expanding)
+
+
+class MyWidget(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("&Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ self.angle = LCDRange("ANGLE", self, "angle")
+ self.angle.setRange(5, 70)
+
+ self.force = LCDRange("FORCE", self, "force")
+ self.force.setRange(10, 50)
+
+ self.cannonField = CannonField(self, "cannonField")
+
+ self.connect(self.angle, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setAngle)
+ self.connect(self.cannonField, qt.PYSIGNAL("angleChanged(int)"), self.angle.setValue)
+
+ self.connect(self.force, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setForce)
+ self.connect(self.cannonField, qt.PYSIGNAL("forceChanged(int)"), self.force.setValue)
+
+ shoot = qt.TQPushButton("&Shoot", self, "shoot")
+ shoot.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(shoot, qt.SIGNAL("clicked()"), self.cannonField.shoot)
+
+ grid = qt.TQGridLayout(self, 2, 2, 10)
+
+ grid.addWidget(quit, 0, 0)
+ grid.addWidget(self.cannonField, 1, 1)
+ grid.setColStretch(1, 10)
+
+ leftBox = qt.TQVBoxLayout()
+ grid.addLayout(leftBox, 1, 0)
+ leftBox.addWidget(self.angle)
+ leftBox.addWidget(self.force)
+
+ topBox = qt.TQHBoxLayout()
+ grid.addLayout(topBox, 0, 1)
+ topBox.addWidget(shoot)
+ topBox.addStretch(1)
+
+ self.angle.setValue(60)
+ self.force.setValue(25)
+ self.angle.setFocus()
+
+
+qt.TQApplication.setColorSpec(qt.TQApplication.CustomColor)
+a = qt.TQApplication(sys.argv)
+
+w = MyWidget()
+w.setGeometry(100, 100, 500, 355)
+a.setMainWidget(w)
+w.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut13.py b/examples/tut13.py
new file mode 100755
index 0000000..c43d67b
--- /dev/null
+++ b/examples/tut13.py
@@ -0,0 +1,330 @@
+#!/usr/bin/env python
+
+# TQt tutorial 13.
+
+import sys
+import math
+import random
+from python_tqt import qt
+
+
+class LCDRange(qt.TQWidget):
+ def __init__(self, s=None, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+ self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ self.slider.setRange(0, 99)
+ self.slider.setValue(0)
+
+ self.label = qt.TQLabel(" ", self, "label")
+ self.label.setAlignment(qt.TQt.AlignCenter)
+
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.PYSIGNAL("valueChanged(int)"))
+
+ self.setFocusProxy(self.slider)
+
+ l = qt.TQVBoxLayout(self)
+ l.addWidget(lcd, 1)
+ l.addWidget(self.slider)
+ l.addWidget(self.label)
+
+ if s is not None:
+ self.setText(s)
+
+ def value(self):
+ return self.slider.value()
+
+ def setValue(self, value):
+ self.slider.setValue(value)
+
+ def setRange(self, minVal, maxVal):
+ if minVal < 0 or maxVal > 99 or minVal > maxVal:
+ raise ValueError("LCDRange.setRange(): invalid range")
+
+ self.slider.setRange(minVal, maxVal)
+
+ def text(self):
+ return self.label.text()
+
+ def setText(self, s):
+ self.label.setText(s)
+
+
+class CannonField(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ self.ang = 45
+ self.f = 0
+ self.timerCount = 0
+
+ self.autoShootTimer = qt.TQTimer(self, "movement handler")
+ self.connect(self.autoShootTimer, qt.SIGNAL("timeout()"), self.moveShot)
+
+ self.shoot_ang = 0
+ self.shoot_f = 0
+ self.target = qt.TQPoint(0, 0)
+ self.gameEnded = 0
+
+ self.setPalette(qt.TQPalette(qt.TQColor(250, 250, 200)))
+
+ self.barrelRect = qt.TQRect(33, -4, 15, 8)
+
+ self.newTarget()
+
+ def angle(self):
+ return self.ang
+
+ def setAngle(self, degrees):
+ if degrees < 5:
+ degrees = 5
+ if degrees > 70:
+ degrees = 70
+ if self.ang == degrees:
+ return
+ self.ang = degrees
+ self.repaint(self.cannonRect(), 0)
+ self.emit(qt.PYSIGNAL("angleChanged(int)"), (self.ang, ))
+
+ def force(self):
+ return self.f
+
+ def setForce(self, newton):
+ if newton < 0:
+ newton = 0
+ if self.f == newton:
+ return
+ self.f = newton
+ self.emit(qt.PYSIGNAL("forceChanged(int)"), (self.f, ))
+
+ def shoot(self):
+ if self.isShooting():
+ return
+
+ self.timerCount = 0
+ self.shoot_ang = self.ang
+ self.shoot_f = self.f
+ self.autoShootTimer.start(50)
+ self.emit(qt.PYSIGNAL("canShoot(bool)"), (0, ))
+
+ def newTarget(self):
+ r = qt.TQRegion(self.targetRect())
+ self.target = qt.TQPoint(random.randint(200, 390), random.randint(10, 265))
+ self.repaint(r.unite(qt.TQRegion(self.targetRect())))
+
+ def gameOver(self):
+ return self.gameEnded
+
+ def setGameOver(self):
+ if self.gameEnded:
+ return
+ if self.isShooting():
+ self.autoShootTime.stop()
+ self.gameEnded = 1
+ self.repaint()
+
+ def restartGame(self):
+ if self.isShooting():
+ self.autoShootTime.stop()
+ self.gameEnded = 0
+ self.repaint()
+ self.emit(qt.PYSIGNAL("canShoot(bool)"), (1, ))
+
+ def moveShot(self):
+ r = qt.TQRegion(self.shotRect())
+ self.timerCount = self.timerCount + 1
+
+ shotR = self.shotRect()
+
+ if shotR.intersects(self.targetRect()):
+ self.autoShootTimer.stop()
+ self.emit(qt.PYSIGNAL("hit()"), ())
+ self.emit(qt.PYSIGNAL("canShoot(bool)"), (1, ))
+ elif shotR.x() > self.width() or shotR.y() > self.height():
+ self.autoShootTimer.stop()
+ self.emit(qt.PYSIGNAL("missed()"), ())
+ self.emit(qt.PYSIGNAL("canShoot(bool)"), (1, ))
+ else:
+ r = r.unite(qt.TQRegion(shotR))
+
+ self.repaint(r)
+
+ def paintEvent(self, ev):
+ updateR = ev.rect()
+ p = qt.TQPainter(self)
+
+ if self.gameEnded:
+ p.setPen(qt.TQt.black)
+ p.setFont(qt.TQFont("Courier", 48, qt.TQFont.Bold))
+ p.drawText(self.rect(), qt.TQt.AlignCenter, "Game Over")
+
+ if updateR.intersects(self.cannonRect()):
+ self.paintCannon(p)
+
+ if self.isShooting() and updateR.intersects(self.shotRect()):
+ self.paintShot(p)
+
+ if not self.gameEnded and updateR.intersects(self.targetRect()):
+ self.paintTarget(p)
+
+ def paintShot(self, p):
+ p.setBrush(qt.TQt.black)
+ p.setPen(qt.TQt.NoPen)
+ p.drawRect(self.shotRect())
+
+ def paintTarget(self, p):
+ p.setBrush(qt.TQt.red)
+ p.setPen(qt.TQt.black)
+ p.drawRect(self.targetRect())
+
+ def paintCannon(self, p):
+ cr = self.cannonRect()
+ pix = qt.TQPixmap(cr.size())
+ pix.fill(self, cr.topLeft())
+
+ tmp = qt.TQPainter(pix)
+ tmp.setBrush(qt.TQt.blue)
+ tmp.setPen(qt.TQt.NoPen)
+
+ tmp.translate(0, pix.height() - 1)
+ tmp.drawPie(qt.TQRect(-35, -35, 70, 70), 0, 90 * 16)
+ tmp.rotate(-self.ang)
+ tmp.drawRect(self.barrelRect)
+ tmp.end()
+
+ p.drawPixmap(cr.topLeft(), pix)
+
+ def cannonRect(self):
+ r = qt.TQRect(0, 0, 50, 50)
+ r.moveBottomLeft(self.rect().bottomLeft())
+ return r
+
+ def shotRect(self):
+ gravity = 4.0
+
+ time = self.timerCount / 4.0
+ velocity = self.shoot_f
+ radians = self.shoot_ang * 3.14159265 / 180
+
+ velx = velocity * math.cos(radians)
+ vely = velocity * math.sin(radians)
+ x0 = (self.barrelRect.right() + 5) * math.cos(radians)
+ y0 = (self.barrelRect.right() + 5) * math.sin(radians)
+ x = x0 + velx * time
+ y = y0 + vely * time - 0.5 * gravity * time * time
+
+ r = qt.TQRect(0, 0, 6, 6)
+ r.moveCenter(qt.TQPoint(int(x), int(self.height() - 1 - y)))
+ return r
+
+ def targetRect(self):
+ r = qt.TQRect(0, 0, 20, 10)
+ r.moveCenter(qt.TQPoint(self.target.x(), self.height() - 1 - self.target.y()))
+ return r
+
+ def isShooting(self):
+ return self.autoShootTimer.isActive()
+
+ def sizePolicy(self):
+ return qt.TQSizePolicy(qt.TQSizePolicy.Expanding, qt.TQSizePolicy.Expanding)
+
+
+class GameBoard(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("&Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ self.angle = LCDRange("ANGLE", self, "angle")
+ self.angle.setRange(5, 70)
+
+ self.force = LCDRange("FORCE", self, "force")
+ self.force.setRange(10, 50)
+
+ self.cannonField = CannonField(self, "cannonField")
+
+ self.connect(self.angle, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setAngle)
+ self.connect(self.cannonField, qt.PYSIGNAL("angleChanged(int)"), self.angle.setValue)
+
+ self.connect(self.force, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setForce)
+ self.connect(self.cannonField, qt.PYSIGNAL("forceChanged(int)"), self.force.setValue)
+
+ self.connect(self.cannonField, qt.PYSIGNAL("hit()"), self.hit)
+ self.connect(self.cannonField, qt.PYSIGNAL("missed()"), self.missed)
+
+ self.shoot = qt.TQPushButton("&Shoot", self, "shoot")
+ self.shoot.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(self.shoot, qt.SIGNAL("clicked()"), self.fire)
+ self.connect(self.cannonField, qt.PYSIGNAL("canShoot(bool)"), self.shoot, qt.SLOT("setEnabled(bool)"))
+
+ restart = qt.TQPushButton("&New Game", self, "newgame")
+ restart.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(restart, qt.SIGNAL("clicked()"), self.newGame)
+
+ self.hits = qt.TQLCDNumber(2, self, "hits")
+ self.shotsLeft = qt.TQLCDNumber(2, self, "shotsleft")
+ hitsL = qt.TQLabel("HITS", self, "hitsLabel")
+ shotsLeftL = qt.TQLabel("SHOTS LEFT", self, "shotsleftLabel")
+
+ grid = qt.TQGridLayout(self, 2, 2, 10)
+ grid.addWidget(quit, 0, 0)
+ grid.addWidget(self.cannonField, 1, 1)
+ grid.setColStretch(1, 10)
+
+ leftBox = qt.TQVBoxLayout()
+ grid.addLayout(leftBox, 1, 0)
+ leftBox.addWidget(self.angle)
+ leftBox.addWidget(self.force)
+
+ topBox = qt.TQHBoxLayout()
+ grid.addLayout(topBox, 0, 1)
+ topBox.addWidget(self.shoot)
+ topBox.addWidget(self.hits)
+ topBox.addWidget(hitsL)
+ topBox.addWidget(self.shotsLeft)
+ topBox.addWidget(shotsLeftL)
+ topBox.addStretch(1)
+ topBox.addWidget(restart)
+
+ self.angle.setValue(60)
+ self.force.setValue(25)
+ self.angle.setFocus()
+
+ self.newGame()
+
+ def fire(self):
+ if self.cannonField.gameOver() or self.cannonField.isShooting():
+ return
+ self.shotsLeft.display(self.shotsLeft.intValue() - 1)
+ self.cannonField.shoot()
+
+ def hit(self):
+ self.hits.display(self.hits.intValue() + 1)
+ if self.shotsLeft.intValue() == 0:
+ self.cannonField.setGameOver()
+ else:
+ self.cannonField.newTarget()
+
+ def missed(self):
+ if self.shotsLeft.intValue() == 0:
+ self.cannonField.setGameOver()
+
+ def newGame(self):
+ self.shotsLeft.display(15)
+ self.hits.display(0)
+ self.cannonField.restartGame()
+ self.cannonField.newTarget()
+
+
+qt.TQApplication.setColorSpec(qt.TQApplication.CustomColor)
+a = qt.TQApplication(sys.argv)
+
+gb = GameBoard()
+gb.setGeometry(100, 100, 500, 355)
+a.setMainWidget(gb)
+gb.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut14.py b/examples/tut14.py
new file mode 100755
index 0000000..8f7404c
--- /dev/null
+++ b/examples/tut14.py
@@ -0,0 +1,378 @@
+#!/usr/bin/env python
+
+# TQt tutorial 14.
+
+import sys
+import math
+import random
+from python_tqt import qt
+
+
+class LCDRange(qt.TQWidget):
+ def __init__(self, s=None, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+ self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ self.slider.setRange(0, 99)
+ self.slider.setValue(0)
+
+ self.label = qt.TQLabel(" ", self, "label")
+ self.label.setAlignment(qt.TQt.AlignCenter)
+
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.PYSIGNAL("valueChanged(int)"))
+
+ self.setFocusProxy(self.slider)
+
+ l = qt.TQVBoxLayout(self)
+ l.addWidget(lcd, 1)
+ l.addWidget(self.slider)
+ l.addWidget(self.label)
+
+ if s is not None:
+ self.setText(s)
+
+ def value(self):
+ return self.slider.value()
+
+ def setValue(self, value):
+ self.slider.setValue(value)
+
+ def setRange(self, minVal, maxVal):
+ if minVal < 0 or maxVal > 99 or minVal > maxVal:
+ raise ValueError("LCDRange.setRange(): invalid range")
+
+ self.slider.setRange(minVal, maxVal)
+
+ def text(self):
+ return self.label.text()
+
+ def setText(self, s):
+ self.label.setText(s)
+
+
+class CannonField(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ self.ang = 45
+ self.f = 0
+ self.timerCount = 0
+
+ self.autoShootTimer = qt.TQTimer(self, "movement handler")
+ self.connect(self.autoShootTimer, qt.SIGNAL("timeout()"), self.moveShot)
+
+ self.shoot_ang = 0
+ self.shoot_f = 0
+ self.target = qt.TQPoint(0, 0)
+ self.gameEnded = 0
+ self.barrelPressed = 0
+
+ self.setPalette(qt.TQPalette(qt.TQColor(250, 250, 200)))
+
+ self.barrelRect = qt.TQRect(33, -4, 15, 8)
+
+ self.newTarget()
+
+ def angle(self):
+ return self.ang
+
+ def setAngle(self, degrees):
+ if degrees < 5:
+ degrees = 5
+ if degrees > 70:
+ degrees = 70
+ if self.ang == degrees:
+ return
+ self.ang = degrees
+ self.repaint(self.cannonRect(), 0)
+ self.emit(qt.PYSIGNAL("angleChanged(int)"), (self.ang, ))
+
+ def force(self):
+ return self.f
+
+ def setForce(self, newton):
+ if newton < 0:
+ newton = 0
+ if self.f == newton:
+ return
+ self.f = newton
+ self.emit(qt.PYSIGNAL("forceChanged(int)"), (self.f, ))
+
+ def shoot(self):
+ if self.isShooting():
+ return
+
+ self.timerCount = 0
+ self.shoot_ang = self.ang
+ self.shoot_f = self.f
+ self.autoShootTimer.start(50)
+ self.emit(qt.PYSIGNAL("canShoot(bool)"), (0, ))
+
+ def newTarget(self):
+ r = qt.TQRegion(self.targetRect())
+ self.target = qt.TQPoint(random.randint(200, 390), random.randint(10, 265))
+ self.repaint(r.unite(qt.TQRegion(self.targetRect())))
+
+ def gameOver(self):
+ return self.gameEnded
+
+ def setGameOver(self):
+ if self.gameEnded:
+ return
+ if self.isShooting():
+ self.autoShootTime.stop()
+ self.gameEnded = 1
+ self.repaint()
+
+ def restartGame(self):
+ if self.isShooting():
+ self.autoShootTime.stop()
+ self.gameEnded = 0
+ self.repaint()
+ self.emit(qt.PYSIGNAL("canShoot(bool)"), (1, ))
+
+ def moveShot(self):
+ r = qt.TQRegion(self.shotRect())
+ self.timerCount = self.timerCount + 1
+
+ shotR = self.shotRect()
+
+ if shotR.intersects(self.targetRect()):
+ self.autoShootTimer.stop()
+ self.emit(qt.PYSIGNAL("hit()"), ())
+ self.emit(qt.PYSIGNAL("canShoot(bool)"), (1, ))
+ elif shotR.x() > self.width() or shotR.y() > self.height() or shotR.intersects(self.barrierRect()):
+ self.autoShootTimer.stop()
+ self.emit(qt.PYSIGNAL("missed()"), ())
+ self.emit(qt.PYSIGNAL("canShoot(bool)"), (1, ))
+ else:
+ r = r.unite(qt.TQRegion(shotR))
+
+ self.repaint(r)
+
+ def mousePressEvent(self, ev):
+ if ev.button() != qt.TQt.LeftButton:
+ return
+ if self.barrelHit(ev.pos()):
+ self.barrelPressed = 1
+
+ def mouseMoveEvent(self, ev):
+ if not self.barrelPressed:
+ return
+ pnt = ev.pos()
+ if pnt.x() <= 0:
+ pnt.setX(1)
+ if pnt.y() >= self.height():
+ pnt.setY(self.height() - 1)
+ rad = math.atan(float(self.rect().bottom() - pnt.y()) / pnt.x())
+ self.setAngle(int(round(rad * 180 / math.pi)))
+
+ def mouseReleaseEvent(self, ev):
+ if ev.button() == qt.TQt.LeftButton:
+ self.barrelPressed = 0
+
+ def paintEvent(self, ev):
+ updateR = ev.rect()
+ p = qt.TQPainter(self)
+
+ if self.gameEnded:
+ p.setPen(qt.TQt.black)
+ p.setFont(qt.TQFont("Courier", 48, qt.TQFont.Bold))
+ p.drawText(self.rect(), qt.TQt.AlignCenter, "Game Over")
+
+ if updateR.intersects(self.cannonRect()):
+ self.paintCannon(p)
+
+ if updateR.intersects(self.barrierRect()):
+ self.paintBarrier(p)
+
+ if self.isShooting() and updateR.intersects(self.shotRect()):
+ self.paintShot(p)
+
+ if not self.gameEnded and updateR.intersects(self.targetRect()):
+ self.paintTarget(p)
+
+ def paintShot(self, p):
+ p.setBrush(qt.TQt.black)
+ p.setPen(qt.TQt.NoPen)
+ p.drawRect(self.shotRect())
+
+ def paintTarget(self, p):
+ p.setBrush(qt.TQt.red)
+ p.setPen(qt.TQt.black)
+ p.drawRect(self.targetRect())
+
+ def paintBarrier(self, p):
+ p.setBrush(qt.TQt.yellow)
+ p.setPen(qt.TQt.black)
+ p.drawRect(self.barrierRect())
+
+ def paintCannon(self, p):
+ cr = self.cannonRect()
+ pix = qt.TQPixmap(cr.size())
+ pix.fill(self, cr.topLeft())
+
+ tmp = qt.TQPainter(pix)
+ tmp.setBrush(qt.TQt.blue)
+ tmp.setPen(qt.TQt.NoPen)
+
+ tmp.translate(0, pix.height() - 1)
+ tmp.drawPie(qt.TQRect(-35, -35, 70, 70), 0, 90 * 16)
+ tmp.rotate(-self.ang)
+ tmp.drawRect(self.barrelRect)
+ tmp.end()
+
+ p.drawPixmap(cr.topLeft(), pix)
+
+ def cannonRect(self):
+ r = qt.TQRect(0, 0, 50, 50)
+ r.moveBottomLeft(self.rect().bottomLeft())
+ return r
+
+ def shotRect(self):
+ gravity = 4.0
+
+ time = self.timerCount / 4.0
+ velocity = self.shoot_f
+ radians = self.shoot_ang * math.pi / 180
+
+ velx = velocity * math.cos(radians)
+ vely = velocity * math.sin(radians)
+ x0 = (self.barrelRect.right() + 5) * math.cos(radians)
+ y0 = (self.barrelRect.right() + 5) * math.sin(radians)
+ x = x0 + velx * time
+ y = y0 + vely * time - 0.5 * gravity * time * time
+
+ r = qt.TQRect(0, 0, 6, 6)
+ r.moveCenter(qt.TQPoint(int(x), int(self.height() - 1 - y)))
+ return r
+
+ def targetRect(self):
+ r = qt.TQRect(0, 0, 20, 10)
+ r.moveCenter(qt.TQPoint(self.target.x(), self.height() - 1 - self.target.y()))
+ return r
+
+ def barrierRect(self):
+ return qt.TQRect(145, self.height() - 100, 15, 100)
+
+ def barrelHit(self, p):
+ mtx = qt.TQWMatrix()
+ mtx.translate(0, self.height() - 1)
+ mtx.rotate(-self.ang)
+ (mtx, invertable) = mtx.invert()
+ return self.barrelRect.contains(mtx.map(p))
+
+ def isShooting(self):
+ return self.autoShootTimer.isActive()
+
+ def sizePolicy(self):
+ return qt.TQSizePolicy(qt.TQSizePolicy.Expanding, qt.TQSizePolicy.Expanding)
+
+
+class GameBoard(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("&Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ self.angle = LCDRange("ANGLE", self, "angle")
+ self.angle.setRange(5, 70)
+
+ self.force = LCDRange("FORCE", self, "force")
+ self.force.setRange(10, 50)
+
+ box = qt.TQVBox(self, "cannonFrame")
+ box.setFrameStyle(qt.TQFrame.WinPanel | qt.TQFrame.Sunken)
+
+ self.cannonField = CannonField(box, "cannonField")
+
+ self.connect(self.angle, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setAngle)
+ self.connect(self.cannonField, qt.PYSIGNAL("angleChanged(int)"), self.angle.setValue)
+
+ self.connect(self.force, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setForce)
+ self.connect(self.cannonField, qt.PYSIGNAL("forceChanged(int)"), self.force.setValue)
+
+ self.connect(self.cannonField, qt.PYSIGNAL("hit()"), self.hit)
+ self.connect(self.cannonField, qt.PYSIGNAL("missed()"), self.missed)
+
+ self.shoot = qt.TQPushButton("&Shoot", self, "shoot")
+ self.shoot.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(self.shoot, qt.SIGNAL("clicked()"), self.fire)
+ self.connect(self.cannonField, qt.PYSIGNAL("canShoot(bool)"), self.shoot, qt.SLOT("setEnabled(bool)"))
+
+ restart = qt.TQPushButton("&New Game", self, "newgame")
+ restart.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(restart, qt.SIGNAL("clicked()"), self.newGame)
+
+ self.hits = qt.TQLCDNumber(2, self, "hits")
+ self.shotsLeft = qt.TQLCDNumber(2, self, "shotsleft")
+ hitsL = qt.TQLabel("HITS", self, "hitsLabel")
+ shotsLeftL = qt.TQLabel("SHOTS LEFT", self, "shotsleftLabel")
+
+ accel = qt.TQAccel(self)
+ accel.connectItem(accel.insertItem(qt.TQt.Key_Enter), self.fire)
+ accel.connectItem(accel.insertItem(qt.TQt.Key_Return), self.fire)
+ accel.connectItem(accel.insertItem(qt.TQt.CTRL + qt.TQt.Key_Q), qt.tqApp, qt.SLOT("quit()"))
+
+ grid = qt.TQGridLayout(self, 2, 2, 10)
+ grid.addWidget(quit, 0, 0)
+ grid.addWidget(box, 1, 1)
+ grid.setColStretch(1, 10)
+
+ leftBox = qt.TQVBoxLayout()
+ grid.addLayout(leftBox, 1, 0)
+ leftBox.addWidget(self.angle)
+ leftBox.addWidget(self.force)
+
+ topBox = qt.TQHBoxLayout()
+ grid.addLayout(topBox, 0, 1)
+ topBox.addWidget(self.shoot)
+ topBox.addWidget(self.hits)
+ topBox.addWidget(hitsL)
+ topBox.addWidget(self.shotsLeft)
+ topBox.addWidget(shotsLeftL)
+ topBox.addStretch(1)
+ topBox.addWidget(restart)
+
+ self.angle.setValue(60)
+ self.force.setValue(25)
+ self.angle.setFocus()
+
+ self.newGame()
+
+ def fire(self):
+ if self.cannonField.gameOver() or self.cannonField.isShooting():
+ return
+ self.shotsLeft.display(self.shotsLeft.intValue() - 1)
+ self.cannonField.shoot()
+
+ def hit(self):
+ self.hits.display(self.hits.intValue() + 1)
+ if self.shotsLeft.intValue() == 0:
+ self.cannonField.setGameOver()
+ else:
+ self.cannonField.newTarget()
+
+ def missed(self):
+ if self.shotsLeft.intValue() == 0:
+ self.cannonField.setGameOver()
+
+ def newGame(self):
+ self.shotsLeft.display(15)
+ self.hits.display(0)
+ self.cannonField.restartGame()
+ self.cannonField.newTarget()
+
+
+qt.TQApplication.setColorSpec(qt.TQApplication.CustomColor)
+a = qt.TQApplication(sys.argv)
+
+gb = GameBoard()
+gb.setGeometry(100, 100, 500, 355)
+a.setMainWidget(gb)
+gb.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut2.py b/examples/tut2.py
new file mode 100755
index 0000000..80fe48f
--- /dev/null
+++ b/examples/tut2.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+# TQt tutorial 2.
+
+import sys
+from python_tqt import qt
+
+
+a = qt.TQApplication(sys.argv)
+
+quit = qt.TQPushButton("Quit", None)
+quit.resize(75, 30)
+quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+
+qt.TQObject.connect(quit, qt.SIGNAL("clicked()"), a, qt.SLOT("quit()"))
+
+a.setMainWidget(quit)
+quit.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut3.py b/examples/tut3.py
new file mode 100755
index 0000000..277c352
--- /dev/null
+++ b/examples/tut3.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+# TQt tutorial 3.
+
+import sys
+from python_tqt import qt
+
+
+a = qt.TQApplication(sys.argv)
+
+box = qt.TQVBox()
+box.resize(200, 120)
+
+quit = qt.TQPushButton("Quit", box)
+quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+
+qt.TQObject.connect(quit, qt.SIGNAL("clicked()"), a, qt.SLOT("quit()"))
+
+a.setMainWidget(box)
+box.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut4.py b/examples/tut4.py
new file mode 100755
index 0000000..41417f5
--- /dev/null
+++ b/examples/tut4.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+# TQt tutorial 4.
+
+import sys
+from python_tqt import qt
+
+
+class MyWidget(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ self.setMinimumSize(200, 120)
+ self.setMaximumSize(200, 120)
+
+ quit = qt.TQPushButton("Quit", self, "quit")
+ quit.setGeometry(62, 40, 75, 30)
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+
+a = qt.TQApplication(sys.argv)
+
+w = MyWidget()
+w.setGeometry(100, 100, 200, 120)
+a.setMainWidget(w)
+w.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut5.py b/examples/tut5.py
new file mode 100755
index 0000000..19cb6f7
--- /dev/null
+++ b/examples/tut5.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+# TQt tutorial 5.
+
+import sys
+from python_tqt import qt
+
+
+class MyWidget(qt.TQVBox):
+ def __init__(self, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+
+ slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ slider.setRange(0, 99)
+ slider.setValue(0)
+
+ self.connect(slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+
+
+a = qt.TQApplication(sys.argv)
+
+w = MyWidget()
+a.setMainWidget(w)
+w.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut6.py b/examples/tut6.py
new file mode 100755
index 0000000..d10eaa5
--- /dev/null
+++ b/examples/tut6.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+# TQt tutorial 6.
+
+import sys
+from python_tqt import qt
+
+
+class LCDRange(qt.TQVBox):
+ def __init__(self, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+ slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ slider.setRange(0, 99)
+ slider.setValue(0)
+ self.connect(slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+
+
+class MyWidget(qt.TQVBox):
+ def __init__(self, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ grid = qt.TQGrid(4, self)
+
+ for c in range(4):
+ for r in range(4):
+ LCDRange(grid)
+
+
+a = qt.TQApplication(sys.argv)
+
+w = MyWidget()
+a.setMainWidget(w)
+w.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut7.py b/examples/tut7.py
new file mode 100755
index 0000000..3c9deea
--- /dev/null
+++ b/examples/tut7.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+
+# TQt tutorial 7.
+
+import sys
+from python_tqt import qt
+
+
+class LCDRange(qt.TQVBox):
+ def __init__(self, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+ self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ self.slider.setRange(0, 99)
+ self.slider.setValue(0)
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.PYSIGNAL("valueChanged(int)"))
+
+ def value(self):
+ return self.slider.value()
+
+ def setValue(self, value):
+ self.slider.setValue(value)
+
+
+class MyWidget(qt.TQVBox):
+ def __init__(self, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ grid = qt.TQGrid(4, self)
+
+ self.lcdlist = []
+ previous = None
+
+ for r in range(4):
+ for c in range(4):
+ lr = LCDRange(grid)
+
+ if previous:
+ self.connect(lr, qt.PYSIGNAL("valueChanged(int)"), previous.setValue)
+
+ previous = lr
+ self.lcdlist.append(lr)
+
+
+a = qt.TQApplication(sys.argv)
+
+w = MyWidget()
+a.setMainWidget(w)
+w.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut8.py b/examples/tut8.py
new file mode 100755
index 0000000..2e81a94
--- /dev/null
+++ b/examples/tut8.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+
+# TQt tutorial 8.
+
+import sys
+from python_tqt import qt
+
+
+class LCDRange(qt.TQVBox):
+ def __init__(self, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+ self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ self.slider.setRange(0, 99)
+ self.slider.setValue(0)
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.PYSIGNAL("valueChanged(int)"))
+
+ self.setFocusProxy(self.slider)
+
+ def value(self):
+ return self.slider.value()
+
+ def setValue(self, value):
+ self.slider.setValue(value)
+
+ def setRange(self, minVal, maxVal):
+ if minVal < 0 or maxVal > 99 or minVal > maxVal:
+ raise ValueError("LCDRange.setRange(): invalid range")
+
+ self.slider.setRange(minVal, maxVal)
+
+
+class CannonField(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ self.ang = 45
+ self.setPalette(qt.TQPalette(qt.TQColor(250, 250, 200)))
+
+ def angle(self):
+ return self.ang
+
+ def setAngle(self, degrees):
+ if degrees < 5:
+ degrees = 5
+ if degrees > 70:
+ degrees = 70
+ if self.ang == degrees:
+ return
+ self.ang = degrees
+ self.repaint()
+ self.emit(qt.PYSIGNAL("angleChanged(int)"), (self.ang, ))
+
+ def paintEvent(self, ev):
+ p = qt.TQPainter(self)
+ p.drawText(200, 200, "Angle = %d" % (self.ang))
+
+ def sizePolicy(self):
+ return qt.TQSizePolicy(qt.TQSizePolicy.Expanding, qt.TQSizePolicy.Expanding)
+
+
+class MyWidget(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ self.angle = LCDRange(self, "angle")
+ self.angle.setRange(5, 70)
+
+ self.cannonField = CannonField(self, "cannonField")
+
+ self.connect(self.angle, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setAngle)
+ self.connect(self.cannonField, qt.PYSIGNAL("angleChanged(int)"), self.angle.setValue)
+
+ grid = qt.TQGridLayout(self, 2, 2, 10)
+
+ grid.addWidget(quit, 0, 0)
+ grid.addWidget(self.angle, 1, 0, qt.TQt.AlignTop)
+ grid.addWidget(self.cannonField, 1, 1)
+ grid.setColStretch(1, 10)
+
+ self.angle.setValue(60)
+ self.angle.setFocus()
+
+
+a = qt.TQApplication(sys.argv)
+
+w = MyWidget()
+w.setGeometry(100, 100, 500, 355)
+a.setMainWidget(w)
+w.show()
+sys.exit(a.exec_loop())
diff --git a/examples/tut9.py b/examples/tut9.py
new file mode 100755
index 0000000..3eafed7
--- /dev/null
+++ b/examples/tut9.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+
+# TQt tutorial 9.
+
+import sys
+from python_tqt import qt
+
+
+class LCDRange(qt.TQVBox):
+ def __init__(self, parent=None, name=None):
+ qt.TQVBox.__init__(self, parent, name)
+
+ lcd = qt.TQLCDNumber(2, self, "lcd")
+ self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
+ self.slider.setRange(0, 99)
+ self.slider.setValue(0)
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
+ self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.PYSIGNAL("valueChanged(int)"))
+
+ self.setFocusProxy(self.slider)
+
+ def value(self):
+ return self.slider.value()
+
+ def setValue(self, value):
+ self.slider.setValue(value)
+
+ def setRange(self, minVal, maxVal):
+ if minVal < 0 or maxVal > 99 or minVal > maxVal:
+ raise ValueError("LCDRange.setRange(): invalid range")
+ self.slider.setRange(minVal, maxVal)
+
+
+class CannonField(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ self.ang = 45
+ self.setPalette(qt.TQPalette(qt.TQColor(250, 250, 200)))
+
+ def angle(self):
+ return self.ang
+
+ def setAngle(self, degrees):
+ if degrees < 5:
+ degrees = 5
+ if degrees > 70:
+ degrees = 70
+ if self.ang == degrees:
+ return
+ self.ang = degrees
+ self.repaint()
+ self.emit(qt.PYSIGNAL("angleChanged(int)"), (self.ang, ))
+
+ def paintEvent(self, ev):
+ p = qt.TQPainter(self)
+
+ p.setBrush(qt.TQt.blue)
+ p.setPen(qt.TQt.NoPen)
+
+ p.translate(0, self.rect().bottom())
+ p.drawPie(qt.TQRect(-35, -35, 70, 70), 0, 90 * 16)
+ p.rotate(-self.ang)
+ p.drawRect(qt.TQRect(33, -4, 15, 8))
+
+ def sizePolicy(self):
+ return qt.TQSizePolicy(qt.TQSizePolicy.Expanding, qt.TQSizePolicy.Expanding)
+
+
+class MyWidget(qt.TQWidget):
+ def __init__(self, parent=None, name=None):
+ qt.TQWidget.__init__(self, parent, name)
+
+ quit = qt.TQPushButton("&Quit", self, "quit")
+ quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
+ self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
+
+ self.angle = LCDRange(self, "angle")
+ self.angle.setRange(5, 70)
+
+ self.cannonField = CannonField(self, "cannonField")
+
+ self.connect(self.angle, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setAngle)
+ self.connect(self.cannonField, qt.PYSIGNAL("angleChanged(int)"), self.angle.setValue)
+
+ grid = qt.TQGridLayout(self, 2, 2, 10)
+
+ grid.addWidget(quit, 0, 0)
+ grid.addWidget(self.angle, 1, 0, qt.TQt.AlignTop)
+ grid.addWidget(self.cannonField, 1, 1)
+ grid.setColStretch(1, 10)
+
+ self.angle.setValue(60)
+ self.angle.setFocus()
+
+
+qt.TQApplication.setColorSpec(qt.TQApplication.CustomColor)
+a = qt.TQApplication(sys.argv)
+
+w = MyWidget()
+w.setGeometry(100, 100, 500, 355)
+a.setMainWidget(w)
+w.show()
+sys.exit(a.exec_loop())
diff --git a/examples/webbrowser/mainwindow.py b/examples/webbrowser/mainwindow.py
new file mode 100644
index 0000000..14929de
--- /dev/null
+++ b/examples/webbrowser/mainwindow.py
@@ -0,0 +1,1097 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'mainwindow.ui'
+#
+# Created: Sun Dec 5 14:50:47 2004
+# by: The PyTQt User Interface Compiler (pyuic) snapshot-20041203
+#
+# WARNING! All changes made in this file will be lost!
+
+
+from python_tqt.qt import *
+from python_tqt.qtaxcontainer import TQAxWidget
+
+image0_data = [
+"32 32 3 1",
+". c None",
+"a c #000080",
+"# c #808080",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+".......#aaaaaaaaa...............",
+"......#aaaaaaaaaaa.........a....",
+".....#aaa.......aaa.......aa....",
+"....#aaa.........aaaa....aaa....",
+"....aaa...........aaaa..aaaa....",
+"....aa..............aaaaaaaa....",
+"....aa...............aaaaaaa....",
+"....aa...............aaaaaaa....",
+"....aa..............aaaaaaaa....",
+"....aa.............aaaaaaaaa....",
+"....#aa...........aaaaaaaaaa....",
+".....#aa.........aaaaaaaaaaa....",
+"......aa#.......................",
+".......aa#......................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................"
+]
+image1_data = [
+"32 32 142 2",
+"TQt c None",
+"#O c #0010f7",
+"#P c #0021ef",
+"#R c #0021f7",
+"#S c #0021ff",
+"#T c #0029ff",
+"ah c #0031ff",
+"#N c #0829f7",
+"#x c #0831ff",
+"#C c #0839ff",
+"#E c #1029e7",
+"#r c #1039ff",
+"#o c #1042ff",
+"#Q c #1831de",
+"ak c #1831e7",
+"#k c #1842ff",
+"#H c #184aff",
+"aj c #2139e7",
+"#s c #2142de",
+"#G c #214aff",
+".9 c #2152ff",
+"#2 c #2939c6",
+"ag c #2939d6",
+"a# c #2942ce",
+"#p c #2942de",
+"#U c #2952ff",
+"ae c #295aff",
+"#y c #3152de",
+".2 c #3152e7",
+"#I c #315aff",
+"#z c #3163ff",
+"#1 c #394abd",
+"#L c #394ade",
+"#B c #3963ff",
+"#w c #396bff",
+"#V c #4252d6",
+"#l c #4252de",
+"#W c #4263ef",
+"#q c #426bff",
+".1 c #4273ff",
+"#5 c #4a5ad6",
+"#J c #4a73ff",
+"#K c #4a7bff",
+"ac c #4a84ff",
+"ab c #5263c6",
+".T c #5263ce",
+".M c #5273d6",
+".c c #5273e7",
+".U c #527bde",
+"#t c #527bf7",
+"#A c #5284ff",
+"#X c #5a63ad",
+".V c #5a84ef",
+"#F c #5a84ff",
+"#v c #5a8cff",
+"ad c #636bbd",
+".e c #637bc6",
+".W c #637bce",
+".3 c #637bd6",
+".Q c #6384de",
+".5 c #638cef",
+"#b c #638cff",
+"#j c #6394ff",
+"af c #6b73bd",
+"#0 c #6b73c6",
+".S c #6b84ce",
+"#u c #6b94ff",
+".C c #6b9cff",
+"ai c #737bce",
+".z c #7384b5",
+".j c #7384c6",
+"#6 c #738cce",
+".4 c #738cd6",
+".b c #739ce7",
+".I c #73a5ff",
+"#n c #73adff",
+"#Z c #7b84b5",
+".R c #7b8cbd",
+".J c #7b94bd",
+".n c #7ba5e7",
+".P c #7badff",
+"#c c #7bb5ff",
+"#M c #84849c",
+"#3 c #8484ad",
+".i c #848cc6",
+"al c #8494bd",
+"aa c #849cc6",
+".y c #84adff",
+".O c #84b5ff",
+"#a c #84bdff",
+".t c #8c94ad",
+".a c #8c94b5",
+".D c #8c9cbd",
+".m c #8c9cce",
+".A c #8ca5ef",
+".f c #8cadf7",
+".H c #8cbdff",
+"#D c #9494a5",
+"#8 c #9494bd",
+"#9 c #9494c6",
+"a. c #949cbd",
+".r c #94c6ff",
+"#d c #94ceff",
+"#4 c #9ca5ad",
+"#7 c #9ca5b5",
+".u c #9cbdf7",
+".6 c #9cc6ff",
+".0 c #9cceff",
+".x c #9cd6ff",
+".L c #a5a5b5",
+"#Y c #a5a5bd",
+"#e c #a5ceff",
+"## c #a5d6ff",
+".X c #adadb5",
+".k c #adc6ff",
+"#i c #add6ff",
+".E c #b5b5b5",
+".d c #b5b5bd",
+".K c #b5bdc6",
+".F c #b5ceff",
+".N c #b5d6ff",
+".B c #b5deff",
+".s c #bdbdbd",
+".# c #bdbdc6",
+"#. c #bdd6ff",
+".G c #bde7ff",
+"#h c #c6e7ff",
+"#f c #c6efff",
+".w c #c6f7ff",
+".h c #ced6ff",
+".Y c #cee7ff",
+".q c #ceefff",
+".Z c #cef7ff",
+".l c #d6efff",
+".8 c #d6f7ff",
+".o c #deefff",
+".7 c #def7ff",
+"#m c #deffff",
+"#g c #e7ffff",
+".v c #efffff",
+".p c #f7ffff",
+".g c #ffffff",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.#.a.b.c.aTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQt.d.e.f.g.h.iTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQt.d.j.k.g.g.l.mTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQt.a.n.o.g.p.q.r.mTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQt.s.t.u.g.g.v.w.x.y.mTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQt.z.A.g.g.v.B.x.r.C.DTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQt.E.a.F.g.g.v.G.r.H.H.I.JTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.s.s.K.K.KTQtTQt",
+"TQtTQt.L.M.N.g.g.q.x.H.O.y.P.P.Q.LTQtTQtTQt.s.s.K.a.R.S.T.U.V.V.Q.W.X",
+"TQt.#.Q.Y.g.g.Z.0.O.y.P.P.P.P.1.2.3.4.S.e.c.5.f.6.N.l.7.8.Z.0.9.T",
+".s.W#..g.p.Z###a.O.P.P.I.I.P#b#c#d#e.B#f#g.7.8.8.q#h#i.r.H#j#k#l",
+".e#e.g#m.G#d.O.y.P.I.I.I.I.I.I.H.6####.0.r.H#a.O#c.I#n.I#j.1#o#p",
+".5.p#f.x.0.O.y.P.I.I.I.I.I.I.I.I.I.I.I.I.I.I.I.I.I.C.C.C#b#q#r#s",
+"#t##.r.H.O#c.P.I.I.I.I.I.I.C.I.C.C.I.C.I.C.C.C.C#u.C#j#j#v#w#x#p",
+"#y#z#j.I.I.P.I.I.C.C.C.I.I.C.C#j#b#v#v#b#j#j#j#b#j#v#b#v#A#B#C#p",
+"#D#E#k#q#A#j.C.I.C.I.C.C.C.I#F#G#k#k#H#G#I#B.1.1#J#K#K.1#q#z#x#L",
+".s#M#N#r#z#K#b#u.C#u.C.C.I.I#B#O#P#Q#E#P#R#S#T#x#r#r#H.9#U#G#T#V",
+"TQtTQt.z#N#r#I.1#v#j#u#j.C#u.I#W#X#D.s#Y#D#Z#0#1#2#Q#P#P#N#N#T#E#3",
+"TQtTQt.s#4#5#x#H#B#K#v#j#j#j#j#6TQtTQtTQtTQtTQtTQtTQt.s.s.d.X#7#8#9a..X.s",
+"TQtTQtTQtTQt.da##S#k#z#J#v#b#j#vaaTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQt.Eab#x#o#I#K#v#vac.iTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQt.sad#E#rae#q#K#wafTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQt.#.Lagah#k#U#kafTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQt#4#Q#T#xahaiTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQt#4adajakalTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt"
+]
+image2_data = [
+"32 32 142 2",
+"TQt c None",
+"#Y c #0018e7",
+"aa c #0018ef",
+"#E c #0018ff",
+"#Q c #0021ef",
+"#K c #0021ff",
+"a# c #0029ff",
+"a. c #0829ff",
+"#P c #0831ff",
+"#4 c #1021d6",
+"#R c #1021de",
+"#L c #1029d6",
+"#V c #1029e7",
+"#n c #1039f7",
+"#W c #1039ff",
+"#O c #1042ff",
+"ah c #1831ce",
+"#y c #1842ff",
+"aj c #2131c6",
+"#S c #2131ce",
+"#z c #2139de",
+".0 c #2142de",
+"ai c #2142e7",
+".t c #214aef",
+"#D c #214aff",
+".x c #2152ff",
+"al c #2939de",
+"#d c #294ae7",
+"#I c #2952ff",
+"#J c #295aff",
+"#T c #3142bd",
+"#N c #315aff",
+"#s c #3163ff",
+"#F c #394ac6",
+"#G c #3952d6",
+"ag c #395ae7",
+".B c #3963f7",
+"ae c #3963ff",
+".g c #396bff",
+"#U c #424ab5",
+"#2 c #4252b5",
+".J c #425ace",
+"#A c #4263de",
+".b c #426be7",
+"#p c #426bef",
+"#x c #426bff",
+".n c #4273ff",
+".o c #4a63ce",
+"#t c #4a6be7",
+".Q c #4a73de",
+"#3 c #4a73ff",
+"#C c #4a7bff",
+"#Z c #525abd",
+".1 c #526bbd",
+".W c #526bc6",
+".R c #526bce",
+".P c #527be7",
+"#w c #5284ff",
+"#m c #528cff",
+"ac c #5a63bd",
+"ak c #5a6bbd",
+".O c #5a7bf7",
+"#H c #5a84ff",
+"#9 c #5a8cff",
+"af c #636bb5",
+".h c #636bbd",
+"ab c #6384ef",
+"#v c #638cff",
+".w c #6394ff",
+".s c #639cff",
+"#M c #6b73b5",
+".C c #6b73bd",
+"#u c #6b9cff",
+".c c #737bb5",
+".S c #7384ce",
+".N c #738ce7",
+".a c #7394de",
+".8 c #7394ef",
+"#8 c #739cf7",
+"#B c #739cff",
+".A c #73a5ff",
+"#0 c #7b84b5",
+".T c #7b8cbd",
+".9 c #7b94c6",
+"#. c #7b94d6",
+".7 c #7ba5ff",
+".X c #7badff",
+".I c #7bb5ff",
+"#5 c #848ca5",
+".y c #848cad",
+".M c #8494b5",
+"## c #849cd6",
+"#c c #84adff",
+".G c #84b5ff",
+".Z c #84bdff",
+"#o c #8c8cad",
+"#a c #8ca5ce",
+".Y c #8cb5ff",
+".H c #8cbdff",
+"#1 c #9494a5",
+".U c #9494ad",
+"#7 c #949cad",
+"#b c #94ade7",
+".z c #94c6ff",
+".v c #94ceff",
+".j c #9c9cad",
+".u c #9ca5ad",
+"#r c #9cc6ff",
+".m c #9cceff",
+".d c #a5a5a5",
+"#6 c #a5a5ad",
+".V c #a5a5b5",
+".K c #a5adb5",
+".2 c #a5ceff",
+".r c #a5d6ff",
+".L c #adadad",
+".i c #adadb5",
+".p c #adadbd",
+".q c #addeff",
+"#e c #ade7ff",
+"#X c #b5b5b5",
+".D c #b5b5bd",
+".E c #b5b5c6",
+".F c #b5bdc6",
+".f c #b5deff",
+"#q c #b5efff",
+".# c #bdbdbd",
+"ad c #bdbdc6",
+".6 c #bddeff",
+"#i c #bde7ff",
+"#h c #bdefff",
+"#g c #c6f7ff",
+"#l c #cee7ff",
+"#j c #cef7ff",
+"#f c #ceffff",
+".k c #d6efff",
+"#k c #d6f7ff",
+".l c #d6ffff",
+".e c #deefff",
+".5 c #e7ffff",
+".4 c #efffff",
+".3 c #f7ffff",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.#.a.b.c.#TQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.d.e.f.g.h.iTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.j.k.l.m.n.o.pTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.d.f.q.r.m.s.t.cTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.u.q.v.m.r.m.w.x.y.#TQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.u.z.z.z.z.m.m.A.B.C.DTQtTQtTQtTQt",
+"TQtTQt.#.E.F.#.#TQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.j.G.H.z.H.z.m.m.I.n.J.KTQtTQtTQt",
+".L.M.N.O.P.Q.R.S.T.U.E.#.#TQtTQtTQt.V.W.X.H.Y.H.H.z.z.z.Z.g.0.VTQtTQt",
+".1.2.3.4.5.k.6.2.Y.7.8.a.9#.###a#b.Y.G.G.G.G.Y.G.Y.H.z#c.n#d.u.#",
+".b#e#f#g#h#i.f#h#g#g#j#k#k#k.e.4.4#l#c.X.G.G.G.G.G.G.G.H.H#m#n#o",
+"#p.m#q.r.m.m.m.z#r.m.z.m.r.q.q.q.m.H.G.G.X#c.G.G.G.X.X.X.X.7#s.J",
+"#t.v.q.m.z.H.H.H.H.H.Z.Y.G.G.G.G.G.G.G.X#c.I#c.X.X.X.A.A#u#u.n#d",
+"#t.H.r.z.Y.G#c.X.X.X.7.X.X.X.X.X.X.X.X.X.X.X.X.X.7.A#u#v#w#x#y#z",
+"#A.I.m.H.X.X.X.A.A#B.A#B#u#u#u#u#B.X#c.X.X.X.X.A.A#u.w#C.g#D#E#F",
+"#G.s.G.A.w#v#H#w#C.n#x#s#I#y#y#y#J#H.X.7.X.X.7.A#u.w#w#J#y#K#L.U",
+"#M.x.n#N#D#O#P#K#K#Q#Q#R#S#T#U#U#V#W.A.X.A.A#B#u.w.n#D#P#E#L.VTQt",
+"#X.h#V#Q#Y#R#S#U#Z#0#1.p.#.#.#.#.V#2.s.7.A#u#u.w#3#D#P#E#4#5TQtTQt",
+"TQtTQt#6#1#7.D.#.#TQtTQtTQtTQtTQtTQtTQtTQtTQt#6#8#B#u.w#9#s#ya.#E#F.V.#TQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.#.8#9#H#w#s#Wa#aa#2#XTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.#ab#w#C#N#W#K#Eac.#TQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtad.Pae#J#Wa##Vaf#XTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.#ag#W#P#Eah#6TQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.#ai#K#Eaj.jTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.#akalak.iTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt"
+]
+image3_data = [
+"25 25 2 1",
+"# c #000000",
+". c #ffffff",
+".........................",
+".........................",
+".........................",
+".........######..........",
+".......##########........",
+"......####....####.......",
+".....###........###......",
+"....#####........###.....",
+"....##.###........##.....",
+"...###..###.......###....",
+"...##....###.......##....",
+"...##.....###......##....",
+"...##......###.....##....",
+"...##.......###....##....",
+"...###.......###..###....",
+"....##........###.##.....",
+"....###........#####.....",
+".....###........###......",
+"......####....####.......",
+".......##########........",
+".........######..........",
+".........................",
+".........................",
+".........................",
+"........................."
+]
+image4_data = [
+"32 32 3 1",
+". c None",
+"# c #000080",
+"a c #808080",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"...............#########a.......",
+"....#.........###########a......",
+"....##.......###.......###a.....",
+"....###....####.........###a....",
+"....####..####...........###....",
+"....########..............##....",
+"....#######...............##....",
+"....#######...............##....",
+"....########..............##....",
+"....#########.............##....",
+"....##########...........##a....",
+"....###########.........##a.....",
+".......................a##......",
+"......................a##.......",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................"
+]
+image5_data = [
+"32 32 211 2",
+"TQt c None",
+"aJ c #000000",
+"#W c #080800",
+"#N c #100800",
+"#V c #101000",
+"#E c #101008",
+"#M c #181000",
+"#L c #181800",
+"#D c #181808",
+"#F c #181810",
+"as c #211800",
+"#K c #211808",
+"#J c #212110",
+"#G c #212118",
+"#q c #212121",
+"an c #292100",
+"#I c #292110",
+"aN c #292910",
+"#H c #292918",
+"#y c #292921",
+"aF c #312900",
+"#C c #312918",
+"#i c #312929",
+".0 c #313131",
+"#7 c #393100",
+"#U c #393108",
+"aG c #393931",
+".M c #393939",
+"#u c #423939",
+"#c c #424a42",
+"aE c #4a4200",
+"aY c #4a4210",
+".V c #4a4239",
+"#B c #4a4a39",
+".m c #4a4a42",
+"aP c #4a5218",
+".G c #4a5252",
+".z c #4a5a52",
+"aO c #524200",
+"am c #524a00",
+"#T c #524a08",
+"#p c #524a4a",
+".s c #525252",
+"#a c #525a52",
+".7 c #52635a",
+"#b c #526363",
+"az c #5a4a00",
+"#6 c #5a5208",
+"aw c #5a5210",
+".Z c #5a524a",
+".L c #5a5a52",
+".y c #5a5a5a",
+".F c #5a635a",
+"#S c #635208",
+"ax c #635a10",
+".U c #635a52",
+".r c #635a5a",
+"aZ c #636321",
+"## c #63635a",
+".A c #636363",
+"#h c #636b6b",
+"aL c #637329",
+"af c #6b5a00",
+".6 c #6b635a",
+"#o c #6b6363",
+".E c #6b6b63",
+"a4 c #6b7321",
+"aS c #6b7329",
+"aR c #6b7331",
+"aX c #736300",
+"al c #736308",
+"#R c #736b10",
+".T c #736b63",
+"a5 c #737329",
+".i c #73736b",
+".K c #737373",
+"a7 c #737b29",
+"#g c #737b73",
+"a9 c #7b7318",
+"#A c #7b7373",
+"a8 c #7b7b21",
+"aV c #7b7b29",
+"aQ c #7b7b5a",
+".J c #7b7b73",
+".1 c #7b7b7b",
+"b# c #7b8431",
+"a3 c #7b844a",
+".8 c #7b847b",
+"ay c #847308",
+"#5 c #847310",
+"aT c #847b21",
+"b. c #847b29",
+".S c #847b73",
+".d c #847b7b",
+"aW c #848421",
+"a1 c #848429",
+"a0 c #848431",
+"bq c #84844a",
+".H c #848484",
+"ae c #8c7b08",
+"ak c #8c7b10",
+"#j c #8c8484",
+"ba c #8c8c63",
+"a2 c #8c8c7b",
+".x c #8c8c84",
+".2 c #8c948c",
+".9 c #8cada5",
+"aC c #947b08",
+".Y c #947b73",
+"aK c #948c10",
+"#Q c #948c18",
+"a6 c #948c29",
+"#m c #948c84",
+"bp c #949442",
+"aH c #949484",
+".D c #94948c",
+".n c #949494",
+"bn c #949c4a",
+"bl c #949c5a",
+"bj c #949c63",
+".u c #949c94",
+".v c #94a59c",
+"aI c #9c8c10",
+"#4 c #9c8c18",
+"#O c #9c8c29",
+"aM c #9c9418",
+"#r c #9c948c",
+"bo c #9c9c4a",
+"bm c #9c9c52",
+"bk c #9c9c5a",
+"bh c #9c9c6b",
+".k c #9c9c94",
+".a c #9c9c9c",
+"bi c #9ca56b",
+"bf c #9ca573",
+".h c #9ca59c",
+"#f c #9ca5a5",
+".B c #9cbdb5",
+"#P c #a59400",
+"aB c #a59418",
+"#k c #a5948c",
+"ar c #a59c29",
+".N c #a59c8c",
+".P c #a59c94",
+".W c #a59c9c",
+"bg c #a5a573",
+"bd c #a5a584",
+".q c #a5a59c",
+".c c #a5a5a5",
+"be c #a5ad7b",
+".o c #a5ada5",
+".C c #a5adad",
+".I c #a5b5ad",
+"#d c #a5bdb5",
+".w c #a5c6bd",
+"ad c #ad9c10",
+"aj c #ad9c18",
+"#w c #ad9c94",
+".f c #ada59c",
+"bc c #adad7b",
+"bb c #adad84",
+".# c #adada5",
+".t c #adadad",
+".4 c #adb5ad",
+"ai c #b5a518",
+"aq c #b5a529",
+"aD c #b5a542",
+"ao c #b5a54a",
+".O c #b5a594",
+"#v c #b5a59c",
+"at c #b5ad52",
+"#z c #b5ad9c",
+".5 c #b5ada5",
+".j c #b5b5ad",
+".e c #b5b5b5",
+".3 c #b5bdb5",
+".Q c #b5bdbd",
+"#e c #b5cec6",
+"#8 c #bda539",
+"#x c #bda59c",
+"#3 c #bdad29",
+"#X c #bdad31",
+"ag c #bdad42",
+"#n c #bdb5ad",
+".b c #bdbdbd",
+".X c #bdcec6",
+"aU c #c6b510",
+"#. c #c6c6bd",
+".p c #c6cece",
+".g c #c6ded6",
+"ac c #cebd31",
+"#l c #ced6ce",
+"#s c #ced6d6",
+"#t c #cedede",
+"#9 c #d6c610",
+"#2 c #d6c631",
+"ap c #dec608",
+"ah c #dece10",
+"ab c #dece31",
+".l c #deefe7",
+".R c #deefef",
+"au c #e7ce08",
+"a. c #e7d621",
+"a# c #e7d631",
+"aa c #e7d639",
+"#1 c #e7de39",
+"#Y c #efde10",
+"av c #efde21",
+"aA c #efde29",
+"#Z c #f7e729",
+"#0 c #f7e739",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.#.aTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.b.c.d.eTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.f.g.h.i.bTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.j.k.l.e.m.nTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.b.a.o.p.q.r.s.tTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.u.v.w.k.x.y.z.A.bTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.t.k.B.C.k.D.E.F.G.HTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.b.#.#.o.I.b.c.J.K.L.M.tTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQt.a.N.O.P.Q.R.o.S.T.U.V.s.bTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQt.t.N.P.W.k.X.R.P.Y.i.A.Z.0.1TQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQt.b.x.2.w.3.4.I.j.#.5.6.L.F.7.0.cTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQt.n.8.9.p#..o.4.x.x.x##.s#a#b.s#c.bTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQt.t.D.##d#e.h#f.o.P.2.2#g###h.A.z#i.KTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQt.b#j.P.f.P#k.q.4.X#l#m#n.n#o.J.6#p#i#q.cTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQt.W#m#k.O#m#r.5.k#s#t#m.q#r.U.E.T#p#u#i.M.eTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQt.b.x#r.o.t#v.f.o.4.l#l#w#x.f.i#o.E###a.m#y.nTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQt.b.e.c#d.o#z.u.q#f.I.q.#.#.2#A.U.m#B#h.h.j.bTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQt.b#C#D#E#F#G#G#G#H#I#J#K#L#M#N.iTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQt.b#O#P#Q#R#S#T#U#L#M#V#W#N#V#V.iTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQt.b#X#Y#Z#0#0#1#2#3#4#5#6#7#M#V#ATQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQt.b#8#9a.a#aaaaabac#3adaeaf#7#M.JTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQt.bagaha.a##1aaaa#2aiajakalaman#ATQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtaoapa.a#aaaqaraq#3aj#5afamas.JTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtatauava#aw#V#W#Max#4ayafazan.JTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtatahaAaB#W#N#M#V#V#RaCalazas.JTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQt.baDap#Z#Q#N#M#V#M#N#6akafaEaFaG.E#h.JTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtaHaIahaAaB#W#W#N#WaJ#6aKalamaF#WaJaJ#yTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQt.qaLaIahavaM#WaJ#W#DaN#RaealaOan#NaNaPaTQTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQt.jaRaSaTaUavaB#WaNaPaLaVaWaeaX#6aYaZa0a1a2TQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQt.ba3a4a5a5aVa6a1aZa7aSaSa5a8a9a4a5b.b#a5a5.kTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtbaa7a7aVa0b.b#a7b#a0a7a7a7aSaSa7b.aVa0aVaR.#TQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtbbbcbdbebebfbgbhbhbibjbjbkbkblbmbmbnbobpbq.bTQtTQtTQtTQtTQt"
+]
+image6_data = [
+"22 22 165 2",
+"TQt c None",
+".h c #000000",
+".o c #010101",
+"aF c #030303",
+"#n c #060606",
+".H c #080808",
+".r c #0c0c0c",
+".q c #121212",
+"#V c #124e7f",
+"#m c #131313",
+".G c #161615",
+"aI c #172cac",
+".6 c #181818",
+"aH c #1841b2",
+".p c #191919",
+"#8 c #1928ba",
+"#W c #1929ba",
+"aj c #192aba",
+"av c #1a31c2",
+"aE c #1b1b1b",
+"aD c #1b2bc8",
+"at c #1c79d2",
+"ah c #1c7dd4",
+"aA c #1d1d1d",
+"aC c #1d7ad7",
+"#6 c #1d7eda",
+".5 c #1e1e1e",
+"#7 c #1e8ae0",
+"ai c #1e8de0",
+"au c #1e90e0",
+".g c #242424",
+"#5 c #313b6c",
+"aB c #343d8d",
+"#3 c #393939",
+".f c #3d3d3d",
+"ak c #433967",
+"#C c #434442",
+"aw c #443c6e",
+"#l c #454643",
+"as c #454fa3",
+".4 c #474845",
+"#R c #474846",
+".e c #484848",
+"aG c #4856a0",
+".d c #4a4a4a",
+"#9 c #4c416a",
+".c c #4c4c4c",
+"ag c #4c5cae",
+"#X c #4d4669",
+"#z c #4dc2b2",
+"#P c #4e445a",
+"#G c #53504e",
+".l c #545454",
+".b c #555555",
+"#Q c #595274",
+"#i c #62b2a2",
+".a c #676767",
+"#j c #69b6a3",
+".F c #6f6f6a",
+".K c #6f8b89",
+"ax c #747474",
+"#a c #76a1a0",
+".# c #797979",
+"#A c #7bd7e8",
+"ay c #7d7d7d",
+"#U c #7e7d73",
+".I c #808080",
+".O c #81a3b8",
+"az c #828282",
+"#y c #82d1c0",
+"#S c #848484",
+"#O c #857e7c",
+"#F c #86add2",
+"#k c #86cdda",
+"#N c #89b1bd",
+"#h c #8acec3",
+"#o c #8c8c8c",
+"#L c #8cbbca",
+"al c #8d8d8d",
+".s c #8f8f8f",
+"#H c #909090",
+"#K c #90bac9",
+"#M c #91c4cf",
+"#t c #929292",
+".X c #94c2cf",
+".N c #94c2d0",
+".W c #959595",
+"#B c #96b9cb",
+".3 c #97bede",
+".L c #98c2ce",
+".P c #9b9b9b",
+"a. c #9c9c9c",
+"am c #9d9d9d",
+"#s c #9dbdc4",
+"#b c #9e9e9e",
+"#Y c #a0a0a0",
+"an c #a6a6a6",
+"#v c #a6d1d6",
+".Z c #a7a1a1",
+"#I c #a7a7a7",
+"#D c #a7edde",
+".M c #a8d8e5",
+"#u c #aeaeae",
+"ac c #b1b1b1",
+"a# c #b2b2b2",
+".2 c #b5cbd6",
+".V c #b6b6b6",
+"ar c #b7b7b7",
+"#Z c #b8b8b8",
+"#2 c #bababa",
+".Q c #babbb9",
+"aq c #bbbbbb",
+"#c c #bcbcbc",
+".8 c #bfbfbf",
+"ap c #c0c0c0",
+".1 c #c1d9d2",
+"aa c #c8c8c8",
+"ab c #cacaca",
+"ao c #cbcbcb",
+".Y c #ccf8f1",
+"#J c #cdcdcd",
+".R c #cecece",
+"#p c #d1f9f4",
+"#4 c #d5d5d5",
+"#w c #d5ece4",
+".9 c #d5f6f5",
+"#0 c #d6d6d6",
+".U c #d7d7d7",
+"af c #d8d8d8",
+".x c #dadada",
+".y c #dbdbdb",
+".w c #dcdcdc",
+"#e c #dcf7f4",
+"#1 c #dddddd",
+"ae c #dedede",
+".E c #dfdfdf",
+".z c #e0e0e0",
+"#g c #e0ebe4",
+"#q c #e1edea",
+"#d c #e2e2e2",
+"#x c #e2ebe2",
+".0 c #e2eee5",
+".v c #e3e3e3",
+"## c #e3e7d5",
+"#r c #e4ebd9",
+"#E c #e4f2ec",
+".u c #e5e5e5",
+".S c #e7e7e7",
+".k c #e9e9e9",
+".A c #ebebeb",
+".D c #ededed",
+".t c #f0f0f0",
+"#T c #f4f4f4",
+".n c #f6f6f6",
+".C c #f7f7f7",
+"#f c #f8f5f2",
+".m c #f8f8f8",
+".7 c #f9f9f9",
+"ad c #fafafa",
+"#. c #fbf0eb",
+".J c #fbfbfb",
+".T c #fcfcfc",
+".B c #fdfdfd",
+".j c #fefefe",
+".i c #ffffff",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQt.#.a.b.c.d.d.e.f.g.hTQtTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQt.#.i.i.i.i.i.i.i.i.i.h.hTQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQt.a.j.j.j.j.j.j.i.i.i.h.k.hTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQt.l.m.n.o.p.q.r.s.j.i.h.t.u.hTQtTQtTQtTQt",
+"TQtTQtTQtTQt.e.v.w.x.y.z.A.n.B.B.h.C.D.E.hTQtTQtTQt",
+"TQtTQtTQt.h.h.h.h.h.F.G.H.I.n.J.h.h.h.h.h.hTQtTQt",
+"TQtTQt.h.K.L.M.N.O.h.P.Q.R.S.n.T.j.U.V.W.hTQtTQt",
+"TQt.h.X.Y.Z.0.1.2.3.h.4.5.6.q.r.s.7.v.8.hTQtTQt",
+"TQt.h.9#..###.F.F.F#a.h#b#c#d.m.j.7.v#c.hTQtTQt",
+"TQt.h#e#f.a#g#h#i#j#k.h#l#m.r#n#o.7.v#c.hTQtTQt",
+"TQt.h#p#q.a#r.F.F.F#s.h#t#u.x.n.j.7.v#c.hTQtTQt",
+"TQt.h#v#w.##x#y#z#A#B.h#C#m#m.q#o.7.v#c.hTQtTQt",
+"TQtTQt.h#D.Z#E.F.F#F.h#G#H#I#J.A.7.m.v#c.hTQtTQt",
+"TQtTQtTQt.h#K#L#M#N.h#O#P#Q#R#m.q#S#T#d#c.hTQtTQt",
+"TQtTQtTQtTQt.h.h.h.h.Z#U#V#W#X#Y#Z#0.S#1#2.hTQtTQt",
+"TQtTQtTQtTQt#3.t.v.x#4#5#6#7#8#9a.a#aaabac.hTQtTQt",
+"TQtTQtTQtTQt.6ad.kae.yafagahaiajakalamana..oTQtTQt",
+"TQtTQtTQtTQt.haeaoapaqaqarasatauavawaxayaz.oTQtTQt",
+"TQtTQtTQtTQtTQt.h.h.h.h.haA.oaBaCaiaD.HaEaFTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtaGaHaITQtTQtTQtTQtTQtTQt",
+"TQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQtTQt"
+]
+
+class MainWindow(TQMainWindow):
+ def __init__(self,parent = None,name = None,fl = 0):
+ TQMainWindow.__init__(self,parent,name,fl)
+ self.statusBar()
+
+ self.image0 = TQPixmap(image0_data)
+ self.image1 = TQPixmap(image1_data)
+ self.image2 = TQPixmap(image2_data)
+ self.image3 = TQPixmap(image3_data)
+ self.image4 = TQPixmap(image4_data)
+ self.image5 = TQPixmap(image5_data)
+ self.image6 = TQPixmap(image6_data)
+
+ if not name:
+ self.setName("MainWindow")
+
+
+ self.setCentralWidget(TQWidget(self,"qt_central_widget"))
+ MainWindowLayout = TQHBoxLayout(self.centralWidget(),0,6,"MainWindowLayout")
+
+ self.Frame3 = TQFrame(self.centralWidget(),"Frame3")
+ self.Frame3.setFrameShape(TQFrame.StyledPanel)
+ self.Frame3.setFrameShadow(TQFrame.Sunken)
+ Frame3Layout = TQVBoxLayout(self.Frame3,1,0,"Frame3Layout")
+
+ self.WebBrowser = TQAxWidget(self.Frame3,"WebBrowser")
+ self.WebBrowser.setControl("{8856F961-340A-11D0-A96B-00C04FD705A2}")
+ self.WebBrowser.setFocusPolicy(TQAxWidget.StrongFocus)
+ Frame3Layout.addWidget(self.WebBrowser)
+ MainWindowLayout.addWidget(self.Frame3)
+
+ self.actionGo = TQAction(self,"actionGo")
+ self.actionGo.setIconSet(TQIconSet(self.image0))
+ self.actionBack = TQAction(self,"actionBack")
+ self.actionBack.setIconSet(TQIconSet(self.image1))
+ self.actionForward = TQAction(self,"actionForward")
+ self.actionForward.setIconSet(TQIconSet(self.image2))
+ self.actionStop = TQAction(self,"actionStop")
+ self.actionStop.setIconSet(TQIconSet(self.image3))
+ self.actionRefresh = TQAction(self,"actionRefresh")
+ self.actionRefresh.setIconSet(TQIconSet(self.image4))
+ self.actionHome = TQAction(self,"actionHome")
+ self.actionHome.setIconSet(TQIconSet(self.image5))
+ self.actionFileClose = TQAction(self,"actionFileClose")
+ self.FileNewGroup = TQActionGroup(self,"FileNewGroup")
+ self.FileNewGroup.setUsesDropDown(1)
+ self.actionNewWindow = TQAction(self.FileNewGroup,"actionNewWindow")
+ self.actionSearch = TQAction(self,"actionSearch")
+ self.actionSearch.setIconSet(TQIconSet(self.image6))
+ self.actionAbout = TQAction(self,"actionAbout")
+ self.actionAboutTQt = TQAction(self,"actionAboutTQt")
+
+
+ self.Toolbar = TQToolBar(TQString(""),self,TQt.DockTop)
+
+ self.actionBack.addTo(self.Toolbar)
+ self.actionForward.addTo(self.Toolbar)
+ self.actionStop.addTo(self.Toolbar)
+ self.actionRefresh.addTo(self.Toolbar)
+ self.actionHome.addTo(self.Toolbar)
+ self.Toolbar.addSeparator()
+ self.actionSearch.addTo(self.Toolbar)
+ self.Toolbar_2 = TQToolBar(TQString(""),self,TQt.DockTop)
+
+ self.Toolbar_2.setHorizontallyStretchable(1)
+
+ self.lblAddress = TQLabel(self.Toolbar_2,"lblAddress")
+
+ self.addressEdit = TQLineEdit(self.Toolbar_2,"addressEdit")
+ self.actionGo.addTo(self.Toolbar_2)
+
+
+ self.menubar = TQMenuBar(self,"menubar")
+
+
+ self.PopupMenu = TQPopupMenu(self)
+ self.FileNewGroup_2 = TQPopupMenu(self)
+ self.PopupMenu.setAccel(TQString.null,self.PopupMenu.insertItem(self.FileNewGroup.iconSet(),self.__tr("New"),self.FileNewGroup_2))
+ self.actionNewWindow.addTo(self.FileNewGroup_2)
+ self.PopupMenu.insertSeparator()
+ self.actionFileClose.addTo(self.PopupMenu)
+ self.menubar.insertItem(TQString(""),self.PopupMenu,1)
+
+ self.unnamed = TQPopupMenu(self)
+ self.actionAbout.addTo(self.unnamed)
+ self.actionAboutTQt.addTo(self.unnamed)
+ self.menubar.insertItem(TQString(""),self.unnamed,2)
+
+
+ self.languageChange()
+
+ self.resize(TQSize(812,605).expandedTo(self.minimumSizeHint()))
+ self.clearWState(TQt.WState_Polished)
+
+ self.connect(self.actionHome,SIGNAL("activated()"),self.WebBrowser,SLOT("GoHome()"))
+ self.connect(self.actionRefresh,SIGNAL("activated()"),self.WebBrowser,SLOT("Refresh()"))
+ self.connect(self.actionStop,SIGNAL("activated()"),self.WebBrowser,SLOT("Stop()"))
+ self.connect(self.actionForward,SIGNAL("activated()"),self.WebBrowser,SLOT("GoForward()"))
+ self.connect(self.actionBack,SIGNAL("activated()"),self.WebBrowser,SLOT("GoBack()"))
+ self.connect(self.actionGo,SIGNAL("activated()"),self.go)
+ self.connect(self.actionFileClose,SIGNAL("activated()"),self.close)
+ self.connect(self.actionSearch,SIGNAL("activated()"),self.WebBrowser,SLOT("GoSearch()"))
+ self.connect(self.addressEdit,SIGNAL("returnPressed()"),self.go)
+ self.connect(self.WebBrowser,SIGNAL("NavigateComplete(const TQString&)"),self.addressEdit.setText)
+ self.connect(self.WebBrowser,SIGNAL("TitleChange(const TQString&)"),self.setTitle)
+ self.connect(self.WebBrowser,SIGNAL("NavigateComplete(const TQString&)"),self.navigateComplete)
+ self.connect(self.WebBrowser,SIGNAL("CommandStateChange(int,bool)"),self.setCommandState)
+ self.connect(self.WebBrowser,SIGNAL("BeforeNavigate(const TQString&,int,const TQString&,const TQVariant&,const TQString&,bool&)"),self.navigateBegin)
+ self.connect(self.actionStop,SIGNAL("activated()"),self.navigateComplete)
+ self.connect(self.actionNewWindow,SIGNAL("activated()"),self.newWindow)
+ self.connect(self.actionAbout,SIGNAL("activated()"),self.aboutSlot)
+ self.connect(self.actionAboutTQt,SIGNAL("activated()"),self.aboutTQtSlot)
+
+ self.init()
+
+
+ def languageChange(self):
+ self.setCaption(self.__tr("TQt WebBrowser"))
+ self.WebBrowser.setControl(self.__tr("{8856F961-340A-11D0-A96B-00C04FD705A2}"))
+ self.actionGo.setText(self.__tr("Go"))
+ self.actionGo.setMenuText(self.__tr("Go"))
+ self.actionBack.setText(self.__tr("Back"))
+ self.actionBack.setAccel(self.__tr("Backspace"))
+ self.actionBack.setMenuText(self.__tr("Back"))
+ self.actionForward.setText(self.__tr("Forward"))
+ self.actionForward.setMenuText(self.__tr("Forward"))
+ self.actionStop.setText(self.__tr("Stop"))
+ self.actionStop.setMenuText(self.__tr("Stop"))
+ self.actionRefresh.setText(self.__tr("Refresh"))
+ self.actionRefresh.setMenuText(self.__tr("Refresh"))
+ self.actionHome.setText(self.__tr("Home"))
+ self.actionHome.setMenuText(self.__tr("Home"))
+ self.actionFileClose.setText(self.__tr("Close"))
+ self.actionFileClose.setMenuText(self.__tr("C&lose"))
+ self.FileNewGroup.setText(self.__tr("New"))
+ self.actionNewWindow.setText(self.__tr("Window"))
+ self.actionNewWindow.setAccel(self.__tr("Ctrl+N"))
+ self.actionNewWindow.setMenuText(self.__tr("Window"))
+ self.FileNewGroup.setMenuText(self.__tr("New"))
+ self.actionSearch.setText(self.__tr("Search"))
+ self.actionSearch.setMenuText(self.__tr("Search"))
+ self.actionAbout.setText(self.__tr("About"))
+ self.actionAbout.setMenuText(self.__tr("About"))
+ self.actionAboutTQt.setText(self.__tr("About TQt"))
+ self.actionAboutTQt.setMenuText(self.__tr("About TQt"))
+ self.Toolbar.setLabel(self.__tr("Toolbar"))
+ self.Toolbar_2.setLabel(self.__tr("Toolbar_2"))
+ self.lblAddress.setText(self.__tr("Address"))
+ self.PopupMenu.changeItem(self.PopupMenu.idAt(0),self.__tr("New"))
+ if self.menubar.findItem(1):
+ self.menubar.findItem(1).setText(self.__tr("&File"))
+ if self.menubar.findItem(2):
+ self.menubar.findItem(2).setText(self.__tr("&Help"))
+
+
+ def go(self):
+ print("MainWindow.go(): Not implemented yet")
+
+ def newWindow(self):
+ print("MainWindow.newWindow(): Not implemented yet")
+
+ def setProgress(self,a0,a1):
+ print("MainWindow.setProgress(int,int): Not implemented yet")
+
+ def init(self):
+ pass
+
+ def setTitle(self,a0):
+ print("MainWindow.setTitle(const TQString&): Not implemented yet")
+
+ def setCommandState(self,a0,a1):
+ print("MainWindow.setCommandState(int,bool): Not implemented yet")
+
+ def navigateComplete(self):
+ print("MainWindow.navigateComplete(): Not implemented yet")
+
+ def navigateBegin(self):
+ print("MainWindow.navigateBegin(): Not implemented yet")
+
+ def aboutSlot(self):
+ print("MainWindow.aboutSlot(): Not implemented yet")
+
+ def aboutTQtSlot(self):
+ print("MainWindow.aboutTQtSlot(): Not implemented yet")
+
+ def __tr(self,s,c = None):
+ return tqApp.translate("MainWindow",s,c)
diff --git a/examples/webbrowser/mainwindow.ui b/examples/webbrowser/mainwindow.ui
new file mode 100644
index 0000000..446a717
--- /dev/null
+++ b/examples/webbrowser/mainwindow.ui
@@ -0,0 +1,410 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>MainWindow</class>
+<widget class="TQMainWindow">
+ <property name="name">
+ <cstring>MainWindow</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>812</width>
+ <height>605</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>TQt WebBrowser</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQFrame">
+ <property name="name">
+ <cstring>Frame3</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>1</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="TQAxWidget">
+ <property name="name">
+ <cstring>WebBrowser</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>StrongFocus</enum>
+ </property>
+ <property name="control">
+ <string>{8856F961-340A-11D0-A96B-00C04FD705A2}</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+</widget>
+<menubar>
+ <property name="name">
+ <cstring>menubar</cstring>
+ </property>
+ <item text="&amp;File" name="PopupMenu">
+ <action name="FileNewGroup"/>
+ <item text="New" name="FileNewGroup_2" accel="">
+ <action name="actionNewWindow"/>
+ </item>
+ <separator/>
+ <action name="actionFileClose"/>
+ </item>
+ <item text="&amp;Help" name="unnamed">
+ <action name="actionAbout"/>
+ <action name="actionAboutTQt"/>
+ </item>
+</menubar>
+<toolbars>
+ <toolbar dock="2">
+ <property name="name">
+ <cstring>Toolbar</cstring>
+ </property>
+ <property name="label">
+ <string>Toolbar</string>
+ </property>
+ <action name="actionBack"/>
+ <action name="actionForward"/>
+ <action name="actionStop"/>
+ <action name="actionRefresh"/>
+ <action name="actionHome"/>
+ <separator/>
+ <action name="actionSearch"/>
+ </toolbar>
+ <toolbar dock="2">
+ <property name="name">
+ <cstring>Toolbar_2</cstring>
+ </property>
+ <property name="horizontallyStretchable">
+ <bool>true</bool>
+ </property>
+ <property name="label">
+ <string>Toolbar_2</string>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lblAddress</cstring>
+ </property>
+ <property name="text">
+ <string>Address</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit">
+ <property name="name">
+ <cstring>addressEdit</cstring>
+ </property>
+ </widget>
+ <action name="actionGo"/>
+ </toolbar>
+</toolbars>
+<customwidgets>
+</customwidgets>
+<actions>
+ <action>
+ <property name="name">
+ <cstring>actionGo</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>image0</iconset>
+ </property>
+ <property name="text">
+ <string>Go</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>actionBack</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>image1</iconset>
+ </property>
+ <property name="text">
+ <string>Back</string>
+ </property>
+ <property name="accel">
+ <string>Backspace</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>actionForward</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>image2</iconset>
+ </property>
+ <property name="text">
+ <string>Forward</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>actionStop</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>image3</iconset>
+ </property>
+ <property name="text">
+ <string>Stop</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>actionRefresh</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>image4</iconset>
+ </property>
+ <property name="text">
+ <string>Refresh</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>actionHome</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>image5</iconset>
+ </property>
+ <property name="text">
+ <string>Home</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>actionFileClose</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="menuText">
+ <string>C&amp;lose</string>
+ </property>
+ </action>
+ <actiongroup>
+ <property name="name">
+ <cstring>FileNewGroup</cstring>
+ </property>
+ <property name="text">
+ <string>New</string>
+ </property>
+ <property name="usesDropDown">
+ <bool>true</bool>
+ </property>
+ <action>
+ <property name="name">
+ <cstring>actionNewWindow</cstring>
+ </property>
+ <property name="text">
+ <string>Window</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+N</string>
+ </property>
+ </action>
+ </actiongroup>
+ <action>
+ <property name="name">
+ <cstring>actionSearch</cstring>
+ </property>
+ <property name="iconSet">
+ <iconset>image6</iconset>
+ </property>
+ <property name="text">
+ <string>Search</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>actionAbout</cstring>
+ </property>
+ <property name="text">
+ <string>About</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
+ <cstring>actionAboutTQt</cstring>
+ </property>
+ <property name="text">
+ <string>About TQt</string>
+ </property>
+ </action>
+</actions>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="1241">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade65232365200210543251d2e253d856405bffcbc54103b11c8563600020b03105719c4b530b08072f50880513560a09c080338d5209420294a4451a38c90426621ab5146d10de524a2aa417505445122861a547722bb0c971a3d2aa921c2ae446c6a9431fc85a9064551220e354009653dec00294e712a1ac4e97078a9a9b5e6020013b3f563</data>
+ </image>
+ <image name="image1">
+ <data format="XPM.GZ" length="4494">789ce596497332470c86effe15947573a5f4c1cc30cc542a07ef60bc808dd7540e3d9b6df006186c93ca7f8fba2535ce57be98dc9292313c487a2575f7ccf063a376d53baa6dfc589bbe9ad7fbbc96df99496da3983d3e7efcfec76f7faead87418dfe1a51500bd67f595befbfd6f2daf1f35369014e08a05e6fd4ab96e31e73d0282bc7a7cae23ff3ccfe8170ca6cee9843f51f3b4ec8cff9efccdebf2d2cf9b06bb9417a25c74f98bdff99390a84fb8e49af70f39891b2e40bfbf8b6b0917e87968346a8f5a6cc51c07ab02f2cf1983237552f709c86691e3bbd5be5821998a32067bd1765d13f67563d530a4b3df8b01c523d8ec74059faed086bfc82390e851b8ed3c86485e34365a9bfc5ece3df8433e10bcb5140f5dd3cf0e099f32f99e350cecb5858f2b1c1dc52fda663d334a277c0ecfd5d61c9373973120967969b548fd71b079e797d8e985b21eb63aecceb85e7c299f4ffaa2ce7739359ebc195631387c6ad1f5e302791ccbba72cf173e15cfa2d2cc7619cf1fa63c9dccaa4ff4bcfdc7fa82cfdf7999348f6bf299c4bfd4c59ea0f99535dafca71d60a65ffebca52ff8c3989e47cce98351fb785759e7bcbad65bf0be624ca9a8e87caac0fb1702ef191b2cc9731a7b9ec4f87d934659e27e142f8c671e6eb9d0ae7b2be07cc6924ccf999698a7e4f58f572e64cebb9f393444994e68e4365d9ff7be15caef70766ad678cb0f8f18359ebe109b3af27f199fadd794cf254eb196599774758e77d5496f5dd64a67959af122ef87c639b59eb81d34ba97fe3f4215196f3922acbbc28acf527cc792c7a857029ecf63bcded05efb8a52cf3cc9833ed2f66563dac0b8b1ebe3317ea77f73352173db8f6ccf54a66df0f30fb7c777d9bc214d2cf88d9cf73cfece3ddf3296b66da7fe199d7a32b5cc8feef31fbfe8f99bdde96b0faddf3272bac390665b99e90d9e7ef33972de9d73d7ff3d873255c49fc1b73257ee4f8d2eb5d336b3e8e8535ff86d9e7bbf35f2cf51366ef77cfeb6299df62563f3c0a8b1fdcf3d3569778773f756e66f7fcac967e175f797ffff5dfd9ff4103010d6698a35955030b2cb1c25bbcc3fbd5344861882352b8c5077c5c45836678c267ca7fc1314ebeaf81537cc599eb608e6ff88e1f2b682c705314b6486182dbb8f31d0ddca529f644619ff2db641d3cf82a8bfa9d62d7da670d3cc4233c760a63eaa08d2734478fac8f87ffc833788a6738c073bc20ebe3255eb1069d863e5e3b851bacfb7c6b0d0c30c488f24a3a2d4ddaf1986a3d600b13179be280ef597809e876e206000c69d8ec0e590f32c8a18012b7a0825b9799e018eee0de4e0b4318c103ff2ea2985b78c47d28a487ce276b634cca40356d1655801c3bf044af2136e0195ef8b711be4045ab50ff42e16bdbb6463d8e610253fe3d4855ec3ed80abd9f62397ef9c9e6cee835249bc31bbc731ff0010beacbcdbfaca29f2836a3e839fd1f3acb5cb6fd6e13b6605b34766097d6664cdf0d7faad9813dd827df08daf4de812ddaa7061c4017baf43ea6daef70c8fb0247704c932dc897b94e67da09553a811ef4a94a0f4ee10c069435216b630ae7a43b800b7fc6164ea543ea73ea75663b22a50e5cc215ec50956beaf606ead08080147b64c76403d20ebdc6142268528d3655ee3a1db6f88b535ee015b42081d4205ee1f4f335878501ea7644331dc81acecdb7ef63b86b32eae59956cff63237f92af7319c9a82669c989256bd0b6fa6fabe86bbfe0ecdadb9a399ce61b49a86355adfbedd45736756bc27b30afd161a9a9179585de33bf69fd2f8ebd7b5bf014644b906</data>
+ </image>
+ <image name="image2">
+ <data format="XPM.GZ" length="4494">789ce5965b4f23471085dff915d6d6db2aaac5e3b92aca037703cbc55c8c21ca43cf8c8d0dd85c6c307694ff9eeaaed3bd68771f968d14298a0a109fabebd4e99a9ef17cfad8e81d1f343e7e5a99cecc6c5435aaa1796a7cac9fc7e3c5ef7ffcf6e7ca8756d4909f661c35a20fbfac7ce8cc1a55e3f07ed2b7409702b4badaccfb996563020f5c7ecbf340b9a31c3591dff7ac7943e002cc8e73cf74acdcc27a8a2d37a5be4e1d9f04567f9fc105f25dcfea9726caad62a07c1158f58f94e3087e868ea57fa5fa0be590bfb11c3525affd4e03ebfa25b8507fbcaa1c47ca66e459fdf10c6c30af4dcfda8f5f9513dfffce71e1f5a956967adddfaeb25f4f7b60e8d199e596f42f6bc787ca213f554e5be06dc7a28ffdee282791cedb5c83d19fd795a55ecf4b3fb0ee07ebd312fae796e3283665e238524e2265de031bcc774d396d61be25b8c4fe1f02abfeab67f49f2867decfbd6393b6a03f03438f3bca19fa51cb33fc6f80fd7eae2c27e257e7cb4de5b4045f78d679f24960ddcfb172e6f73357ce63e88fc115ce43e558fcabbeb905fb7e47cae24ff5daca41af007bbd81e5b425f53aff6160d52f95f318f37d01a39ee7ca05f4790a469e0e1c97590bfa1b81f53c3e2bfbf5ecf697b532efe754398f31af437085eb65948b18e723f70cbf9e2bcc633db0f65b533609fcbafb372bf318fdcfc015e65b281731ee0ff6acf70767ca5e8f7be01abcab5cfa7e89e53cce2ba3fd1681b5df8172013f44e00acfbf4a39e8ef287b7dbe02234feefce795d727a36c12ccf75239d4b7c1bede9def42fcc0ef7960d5cbc05ebf543635aed752b94aa1ff02ee83ddf3b6a87c3d3f2b9b047a4fcaa17e0cf6f5eef928ab13f5476960d5eb7ac6f5dd07d7e04839e83d29d7be9ffbfe31b50dc723cfa87f08acf947e51a7ad457ee6760773ecaa4f47e36036bfd96673c3fb6c13578a01cf41f9505d5af3b2f655dc28fa93da33e550ef523e5e06f08861eb9e7b94cdfe7ddf753d50feb6f94437e00f67edcf3aa4e831ed8afe73bb05fefe655f7c37edcfd62bb81ddfb82935776cfeb41c87766ff2cfe7f1a4c6cb8e48ae91f68d4dce7015ff390473fad71c3b77cc7639ef03d3ffcb48f013ff293a84c79c6d54f693c8bc28b28589539bff2e2ed647e586389184bacf13a6ff0e6d71a32f92dde96bfdf9dbccc6387dba2d086caae4c668ff7bf68f0673ee0433ee263eef0099ff2199f8b62d0e32e5f704fea2fe5b70d3f57729556b91b349a1c718b634e64faa9fc7fc919e772220a91213254ca273b884bf72b4a54f1846ad925e93b1af56940d734a4110fe4efb5c40dddda907311734c7752d10b3a1ae289c634a17b7dafe331e995b3b124fbdfd25d85471763596fab7aa2a4f53d444653ded3773bb96e8faeae1de2ea8dff9da0b0ebfcd858e3357aa667bb1f68b4a5e7d256853559e8f56d64aefe85e6f44a0b5aea3bac5c2bebf74b8775fb6bfbb858771e7a6f1df09c36f89a36698bb6f53d5c4ef08ee4e6a2dd269b9d488729ed4a171b7bd40ece3228cce5d305edd3673ed7773139bd133a14d5233a96cff7a9237142a77446e7125dba900e70681564f5a6acdc1285ae9e0feaf150d675e8d2d59dd315ad52931fec2973d1a5489c6698e29c5a508829797bd629a52665bcf9fdd32ed95c1d50217b5c18b67390f34befb8e78873a9b6b39ad285216328a2de3bef5b32a59db5ccec42a6b565aaf7dffba6e663d3972b211ea86b065f3cbccbc7b53890399a21a55f677f5863e4f670c337df667f58e3d6dc99dbef3dd5ff6bdf73ff82c65fbfaefc0d4fb5b868</data>
+ </image>
+ <image name="image3">
+ <data format="XPM.GZ" length="802">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade65232325500210543251d2e25658564056503300071f540dc3430007371012a492a830156496538c094848922c9c2259134c099304914e3604c8424aa5e6449b0044216ca824ba2da8b4512218b4d122e8b55520fee5974072164511da487ea490c7f22cba249e20d3efc018f3fcae0d2702eb5d2106992b5d65c00b9a48974</data>
+ </image>
+ <image name="image4">
+ <data format="XPM.GZ" length="1241">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade65232365200210543251d2e253d856405bffcbc54105b19c8563600020b03103711c4b530b08072f50880513524ab518681443435ca984ae08ae06a94114a10ac443435ca3043904d4c4453a38ca604ae11590d9a0ab80bd0d46078914c35c4d885a608871a547f61f81d5d117a1862018930e5b8d5c0950c741a1b1e6a6aadb90086a9d853</data>
+ </image>
+ <image name="image5">
+ <data format="XPM.GZ" length="5598">789ca5985973db480ec7dff3295cc15b6a0b2351a428d6d63ef83e255bbe647b6a1fd02465dd872d9f53f3dd076c005dc926ce6a32eed8553f37fadf7fa0c1a69cdfbe6cdc9cb537befcf6e97145ab61be910fe861e34bf1349dbefdfedffffcf1e97323dae07f51bdbe117dfed7a7cfddd546bed199cfca0ae888016afeab62e8796ef110ee545caf05be16ae5bfc6ee096e7b6e756983f51b6f53b81257ecfb8eee7e9b162f66af1c78125fe48987f23f3fb81657e691cd5bddecc7316d555efd058f7eb2867aa771058f4de8c55cffb6dd4a34cf5b68d357e681c6515634db81a7e3ef59c35cccf5560bf9ef6953389c77660af074f15c751e05c38a6d81f2ef9f3a848f4e9d658f2c36b635dbfa54cc2383556bd33e12492fc70df38f1f3f8ae4cc2745a711285fda7caa4f95e06967a2d8c63f27a8fc2a60fa4acfa980a371b898f0767dc6cf8fdbc9f84c27e4de124d2fabe186b3dee8c75ff1365dbef2db0ccef0987fd2f2a6632fd576552fd2b63d57b08ecd7d39d70b321fd0560acfb6d1a4b7e3050764de7d79f08a70de937ea7b7689e68f4de1e0776e2c7ab8abecb47eb170aa7ee822b0e89f1b4b7fd24dc529abe9794f02cbf99e2b3badc7a5b1ee97089b3e0e8d253f3c364e253e5576120ff7c63a9f7966d2e771d358e75bca4ef3bb0e2cf9758db5fe47c6b21eeb81bd3f07c2ad58ebd130d67e6a194b3cf97e62b2fa24c67a1f5d2aab3f8781a53e17c6eaa7082cfa3de156acf9d5034b7e3563f1eb96c6eaf7c0b815fbf8d2739e3aedefb1b1de9723618b77a49cebf946c6e20f5f8d251e753e8b5bb9e74c980a4afc7a7fbf66b1ed8fb7c67a9ec7c2ad5cfd74038bdfa6b1f6cbd458fd2e84b358efbb0363f5b71358fccd8c33596f9c4bfddcc458fac78d8cf5797b3296f5f82c4c49e6f5c9bf9fb23ce41307967e3935d6f36c0b67b1ce3f188b5f3757367f5363b98fdc38b0cc0f8cf5f90bf3ea97028bfe50981289777d63edcf81b1c4439897f3c52d615738cfe0df371c1deb7db265acf98d8d253f7a50d67a60c758cfcbf4cc7f2fb0f8bf1736bfae30d6f35f1a4b3ce6c6e2df95ca85f6f7dc58f3db0e5c783e14e6ebc533e87e963fbe0873f9fd3cc97c91693fd028b0d4e3c558f3eb0b9b5f972bab3fe78c353f3056bfabc0e2371636bfe4cf9b29d1e76b69acfdb863accfd33cb0dc2fa7c6e2179e03cb79ae940b7dffbf1b6bfd1363f53b12367f581a6b3d1bca56df6e60a9bfc6e765def4ecef6bc7eafaf9e8d558fbb7a15ce87d7263acf7ffbdb1e40f33e1e0cf29ebfea8eb6d7ff29f17f8f4137dfe51d8fa0117ca65ee3fbfe3bd705116b2de9f775e3af50313e1a229f1f0682cf1b052e6e1d9dfbf1cddd4fd2363cdcfef5fb05b7d1f0c944bed4f67ac9f5f27c265bf4c3d9f07eefb787f1f96695eaa1e0a174d7d7f81b1ee4f81a5fe75e552d9bf1fca7e617e9e8d556f33b0c4fbcf5ffdb44c956bc6a2d75dfd6c2020fd3ce2ff69a0c31c0b2cff91461fef71804374bfaa81231ce3044b9ce2ecd734380fc2392e70890ff888bfa6f184cff8c24e5ef10ddf71f3a37c3ed6c015afdec26dfeb983bbb887fb78f0f734380fe031c7437f3247788c27d8fe713e1f6a1076f014cfb08be7ac7481977885d75c951fe4f3630dcea3c3eb7b9cc70d6b9ce12d9fee26de610debeb69b0fb578cb89a0d8c399711e794609373d9c39455f2b53466d8c20c17809c45cc7a3c00f011081cffccff379fef35388f1d0428a0c401f459e58c3d45700f0003cee71d8678fc730d7430e2557d3c8331f7568c37308129cc7006733e9d262c6008cb6ff3f94ea3c72bc678ca3f1fb80a637884154c71c974c55d72c91a4feca4fdf553f8ad46554d8e9ee30a9eb1efab31611f2ff0ca346427bb9c11e114debe7e7ebed328318702e7f0ce9dbee47a1c724655b745b0c94ea6b0c55519f059b98f73d19a6cc30eecc21eecfb7100877004c770026de8e070bdfe805338832e9cc3055cc2955f7b0d3de8f0cfebb5356ee016eea0c6a30e11342086049a907aadcd35355a90111250f5e5288706bfdb4bea572a78b49e06ddd3a0d2807a2502110d6944639ad09466ebf9e8ae684e0bf5b1a4075ab28f11ffa1df678dc7f57cb0c68a9ee899355e7c2ddbf40a31bdb1c63bcdfe86c6803669cb9f4555c76b38a76dcee57d5d1f5c8f1d5af0b9745581bb029a5c8f3eedd21eed73b70ebe56fa91061dd061f05139e9d1116b1cfb9aee55c4fcf6330d5cd289d778a6b65fdd831dea702e256b9cf2b974a84367d4fd580347744e17744957acc13e7cfc095d538f356ed8cd2ddd518dea147da4c1956890ffcf295ed5e4c83b4a59f182b9455935e3b801ab791c7fa4e188d7a4bcbee66353feaef9df8852ca2f3e9ee3ef73840f359cabfec22979f4ddbd1bf018ba118f318f899bf298b9b95bb8e537cffe9ffffef4171c39a0bf</data>
+ </image>
+ <image name="image6">
+ <data format="XPM.GZ" length="3742">789c8d96c9521c490c86ef3c458775734cc8ddd5b5c6c41c303b180cc60b66620eaacc2c9aa5599b7562de7da45fc5180c8e98fa39f091522e4a49c9bbb783bdedcdc1db77735733991d864198c8e5e06dbc9e4eeffffceb8fbfe7de64d9407f466531c8defc36f76667360883adb3d364c013051ae2039f8147266359068f4dc6740a2e4db05f05d726f0253898c017c6a3cc04ffafce79aa3af0143c36c17e055caa0aacbf06aeb2203e5f09ae4d185f75ce472de6e7737063c2fcb57356b702fed673e32c473d4bcf3760198f02e69325706b022f3a676df0f567e05035d1ed273dc79883e7c1d1045e70ae2456d84fd9738a589f0b703261bc72ae25e17ee4b0e7d8f3b5733374e603e32c37c11ff36970db12f193f7e07c1c6bec87c6e0c604ff0e1c4db03f36cec7e3a6f4fd2e38e779eee7bd05e7e350fa7e4fc0455ee6b84fb9eab913bfdf1c5ce5758efba54fffb1e75302d726f8af3817a5f8f922584cf06fc0211f951ebfd0b30afe07ce4510dfdf1e38e665e9f9f1e01c32cf1fda06a73c2f7c7eac5f8c8b61eef582f315b909dc82f1c17e07dc1459e5f1c77d953abb787e0ab832611cf957366dd9c707f556762a3fcf8673ddd6d8afdc1957b909fe98af2a65d4c787c08d09e3c8bfaad504f378de83a309e35fc049d9d747bda19c7dbe8f602d88d6fd11af3a33c1ffde398e02ec69178c0b04bb7fa12be03e08e7ab4b895e2f74ec1ca2e73f6d811b2d37df1feaa9969082f71ff4a73a98c01f9cdb3678fde27eea58f7f9cdc8bfba33c11efda2199ac01bcead048fd72678a4e9e3f6a86f6d172acc87fc69f290f9386f3d72f478a1bf348509fea8b7a66c9b80fec1a8b7a66a53f47cc2fe9b5ae77346fe35ad09e761703081d12f9b68c2fc57ce6d0c1e6fe463934ce0efc63234c11ffd5b4a13c66f9cb53d79fded832bcd27f47f5aeb59055e744eb1df3fe2251aeee4e7453f9264c27aa847b44f7f4f909fda3efb7ae30c5c84b65f1fef435b9a608ff7a4ad4c981ffb6b6b13d8fda5edfb37eff4dcb65e2f787f5a7cb0f7fd0413ecf13eb49d09f6783ff07cf97d8ec0a3f8d8df516f483faf07c45b1f27e9f30ff989e9fdbe11ff1034fd3c9eebe068c238fa9f6677f2fb27ac1f475dd3f97da25fc6c204be755673ef3f8db3360c1f1f824b13c651df2877c44fd0df511efe5ea39f44318151cf9a4e2ab0af870d63fee4dc55fdfe109f880ff3fb788a8ff98df733762630fa471aa6febda2839e5b3f0fe1bef4f18bc9fb01fa7dca4ce0bb9e5b671ef69c3cff18f99cc626d853cf551f3fe453ca531bbdde979cbb2c793e207f536102a39fa5ca0446bf4279f97b89feaabb5181511f38bedf2ffa47373461bdcfe0dc8471d46387860fc6fbaad155c11ef7a5d953747ede69cf2a30fe3fd06c5121fe88572726f8a37f68720ffbfdadf7ac02fb7e82098c7e85ebf2fde37dea92098cf7acc367bc33fbff7a6ecfc4c22d078eaac41d1ff0e4d7f66a7df84293e71ecfec858f9ee8d1fef8a9c733fb139ef2299ff1395ff0255fc167c233befee1f1cc3ef10ddff21ddff303cfabe77bd584177891971e3d7ed8db4e7b2df30aaff29a7aac3ff9ebe4a9bdf2067fe04ddee28ffafb36eff027de558fcfbaab2ffc95bf3db5578b3dfecefb3ce411673c56ceb9e0b23f47a5fbac7fb26f889988742f2a129e504b81a246e0c8ec293cb7a7441d0b1dd0840ee9883486744253bea4533a7bd5fe9c2ed4feb29fff4aff32a36b8dd5e92fe6bfa15bddcf1dddd303cd93c6911668aa2b5cbc363f3c16799f9630fbb2d20aadd21aadeb3d547a8617f6f0d8a00fb4495bfadb47daa61dfa84f977e933c597f64f6e6c9fbed057fa467bf49df669c8bb34a2eca53d8d35576ef88e722aa8a48a6a6a448320a20fd36bf3eb7f407c2c89efb5500f6422877224c77222533915e6b397fbd117f54ccee54275295732936bb9915bb9937b797869ff34e7649ecfe4bd2ce81a8bbc2a4bb2fc5a3dfe2c59915559fb75fdfe8f7affe7f7b97f011cdd9635</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>actionHome</sender>
+ <signal>activated()</signal>
+ <receiver>WebBrowser</receiver>
+ <slot>GoHome()</slot>
+ </connection>
+ <connection>
+ <sender>actionRefresh</sender>
+ <signal>activated()</signal>
+ <receiver>WebBrowser</receiver>
+ <slot>Refresh()</slot>
+ </connection>
+ <connection>
+ <sender>actionStop</sender>
+ <signal>activated()</signal>
+ <receiver>WebBrowser</receiver>
+ <slot>Stop()</slot>
+ </connection>
+ <connection>
+ <sender>actionForward</sender>
+ <signal>activated()</signal>
+ <receiver>WebBrowser</receiver>
+ <slot>GoForward()</slot>
+ </connection>
+ <connection>
+ <sender>actionBack</sender>
+ <signal>activated()</signal>
+ <receiver>WebBrowser</receiver>
+ <slot>GoBack()</slot>
+ </connection>
+ <connection>
+ <sender>actionGo</sender>
+ <signal>activated()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>go()</slot>
+ </connection>
+ <connection>
+ <sender>actionFileClose</sender>
+ <signal>activated()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>close()</slot>
+ </connection>
+ <connection>
+ <sender>actionSearch</sender>
+ <signal>activated()</signal>
+ <receiver>WebBrowser</receiver>
+ <slot>GoSearch()</slot>
+ </connection>
+ <connection>
+ <sender>addressEdit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>go()</slot>
+ </connection>
+ <connection>
+ <sender>WebBrowser</sender>
+ <signal>NavigateComplete(const TQString&amp;)</signal>
+ <receiver>addressEdit</receiver>
+ <slot>setText(const TQString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>WebBrowser</sender>
+ <signal>TitleChange(const TQString&amp;)</signal>
+ <receiver>MainWindow</receiver>
+ <slot>setTitle(const TQString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>WebBrowser</sender>
+ <signal>NavigateComplete(const TQString&amp;)</signal>
+ <receiver>MainWindow</receiver>
+ <slot>navigateComplete()</slot>
+ </connection>
+ <connection>
+ <sender>WebBrowser</sender>
+ <signal>CommandStateChange(int,bool)</signal>
+ <receiver>MainWindow</receiver>
+ <slot>setCommandState(int,bool)</slot>
+ </connection>
+ <connection>
+ <sender>WebBrowser</sender>
+ <signal>BeforeNavigate(const TQString&amp;,int,const TQString&amp;,const TQVariant&amp;,const TQString&amp;,bool&amp;)</signal>
+ <receiver>MainWindow</receiver>
+ <slot>navigateBegin()</slot>
+ </connection>
+ <connection>
+ <sender>actionStop</sender>
+ <signal>activated()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>navigateComplete()</slot>
+ </connection>
+ <connection>
+ <sender>actionNewWindow</sender>
+ <signal>activated()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>newWindow()</slot>
+ </connection>
+ <connection>
+ <sender>actionAbout</sender>
+ <signal>activated()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>aboutSlot()</slot>
+ </connection>
+ <connection>
+ <sender>actionAboutTQt</sender>
+ <signal>activated()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>aboutTQtSlot()</slot>
+ </connection>
+</connections>
+<forwards>
+ <forward>class TQProgressBar</forward>
+</forwards>
+<variables>
+ <variable>TQProgressBar *pb;</variable>
+</variables>
+<slots>
+ <slot>go()</slot>
+ <slot>newWindow()</slot>
+ <slot>setProgress( int a, int b )</slot>
+ <slot>init()</slot>
+ <slot>setTitle( const TQString &amp; title )</slot>
+ <slot>setCommandState( int cmd, bool on )</slot>
+ <slot>navigateComplete()</slot>
+ <slot>navigateBegin()</slot>
+ <slot>aboutSlot()</slot>
+ <slot>aboutTQtSlot()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includes>
+ <include location="global" impldecl="in implementation">qaxwidget.h</include>
+</includes>
+</UI>
diff --git a/examples/webbrowser/webbrowser.py b/examples/webbrowser/webbrowser.py
new file mode 100644
index 0000000..12f6f1c
--- /dev/null
+++ b/examples/webbrowser/webbrowser.py
@@ -0,0 +1,91 @@
+# Copyright (C) 2001-2002 Trolltech AS. All rights reserved.
+# Copyright (C) 2004 Riverbank Computing Ltd. All rights reserved.
+#
+# This file is part of an example program for the ActiveTQt integration.
+# This example program may be used, distributed and modified without
+# limitation.
+
+
+import sys
+from python_tqt import qt
+from python_tqt import qtaxcontainer
+
+import mainwindow
+
+
+class MainWindowImpl(mainwindow.MainWindow):
+ def init(self):
+ self.pb = qt.TQProgressBar(self.statusBar())
+ self.pb.setPercentageVisible(False)
+ self.pb.hide()
+ self.statusBar().addWidget(self.pb, 0, True)
+
+ self.connect(self.WebBrowser, qt.SIGNAL("ProgressChange(int,int)"), self.setProgress)
+ self.connect(self.WebBrowser, qt.SIGNAL("StatusTextChange(const TQString&)"), self.statusBar(), qt.SLOT("message(const TQString&)"))
+
+ self.WebBrowser.dynamicCall("GoHome()");
+
+ self.subwindows = []
+
+ def go(self):
+ self.actionStop.setEnabled(True)
+ self.WebBrowser.dynamicCall("Navigate(const TQString&)", qt.TQVariant(self.addressEdit.text()))
+
+ def setTitle(self, title):
+ self.setCaption("TQt WebBrowser - " + title.latin1())
+
+ def setProgress(self, a, b):
+ if a <= 0 or b <= 0:
+ self.pb.hide()
+ return
+
+ self.pb.show()
+ self.pb.setTotalSteps(b)
+ self.pb.setProgress(a)
+
+ def setCommandState(self, cmd, on):
+ if cmd == 1:
+ self.actionForward.setEnabled(on)
+ elif cmd == 2:
+ self.actionBack.setEnabled(on)
+
+ def navigateBegin(self):
+ self.actionStop.setEnabled(True)
+
+ def navigateComplete(self):
+ self.actionStop.setEnabled(False)
+
+ def newWindow(self):
+ window = MainWindowImpl()
+ window.show()
+
+ if self.addressEdit.text().isEmpty():
+ return
+
+ window.addressEdit.setText(self.addressEdit.text())
+ window.actionStop.setEnabled(True)
+ window.go()
+
+ self.subwindows += window
+
+ def aboutSlot(self):
+ qt.TQMessageBox.about(self, self.tr("About WebBrowser"), self.tr(
+"""This Example has been created using the ActiveTQt integration into TQt Designer.
+It demonstrates the use of TQAxWidget to embed the Internet Explorer ActiveX
+control into a TQt application."""))
+
+ def aboutTQtSlot(self):
+ qt.TQMessageBox.aboutTQt(self, self.tr("About TQt"))
+
+
+def main(args):
+ a = qt.TQApplication(args)
+ w = MainWindowImpl()
+ a.setMainWidget(w)
+ w.show()
+
+ return a.exec_loop()
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))
diff --git a/examples/widgets.py b/examples/widgets.py
new file mode 100755
index 0000000..fe36049
--- /dev/null
+++ b/examples/widgets.py
@@ -0,0 +1,500 @@
+#!/usr/bin/env python
+
+
+import sys, string
+from python_tqt.qt import *
+
+#
+## Constructs an analog clock widget that uses an internal TQTimer.
+#
+def TQMIN( x, y ):
+ if y > x:
+ return y
+ return x
+
+#
+## Constructs an analog clock widget that uses an internal TQTimer.
+#
+
+class AnalogClock( TQWidget ):
+ def __init__( self, *args ):
+ TQWidget.__init__(*(self,) + args)
+ self.time = TQTime.currentTime() # get current time
+ internalTimer = TQTimer( self ) # create internal timer
+ self.connect( internalTimer, SIGNAL("timeout()"), self.timeout )
+ internalTimer.start( 5000 ) # emit signal every 5 seconds
+
+#
+## The TQTimer::timeout() signal is received by this slot.
+#
+
+ def timeout( self ):
+ new_time = TQTime.currentTime() # get the current time
+ if new_time.minute() != self.time.minute(): # minute has changed
+ self.update()
+
+#
+## The clock is painted using a 1000x1000 square coordinate system.
+#
+ def paintEvent( self, qe ): # paint clock
+ if not self.isVisible(): # is is invisible
+ return
+ self.time = TQTime.currentTime() # save current time
+
+ pts = TQPointArray()
+ paint = TQPainter( self )
+ paint.setBrush( self.foregroundColor() ) # fill with foreground color
+
+ cp = TQPoint( self.rect().center() ) # widget center point
+ d = TQMIN( self.width(), self.height() ) # we want a circular clock
+
+ matrix = TQWMatrix() # setup transformation matrix
+ matrix.translate( cp.x(), cp.y() ) # origin at widget center
+ matrix.scale( d / 1000.0, d / 1000.0 ) # scale coordinate system
+
+ h_angle = 30 * ( self.time.hour() % 12 - 3 ) + self.time.minute() / 2
+ matrix.rotate( h_angle ) # rotate to draw hour hand
+ paint.setWorldMatrix( matrix )
+ pts.setPoints( [ -20,0, 0,-20, 300,0, 0,20 ] )
+ paint.drawPolygon( pts ) # draw hour hand
+ matrix.rotate( -h_angle ) # rotate back to zero
+
+ m_angle = ( self.time.minute() - 15 ) * 6
+ matrix.rotate( m_angle ) # rotate to draw minute hand
+ paint.setWorldMatrix( matrix )
+ pts.setPoints( [ -10,0, 0,-10, 400,0, 0,10 ] )
+ paint.drawPolygon( pts ) # draw minute hand
+ matrix.rotate( -m_angle ) # rotate back to zero
+
+ for i in range( 0, 12 ): # draw hour lines
+ paint.setWorldMatrix( matrix )
+ paint.drawLine( 450,0, 500,0 )
+ matrix.rotate( 30 )
+
+
+class DigitalClock( TQLCDNumber ):
+ def __init__( self, *args ):
+ TQLCDNumber.__init__(*(self,) + args)
+ self.showingColon = 0
+ self.setFrameStyle(TQFrame.Panel | TQFrame.Raised)
+ self.setLineWidth( 2 )
+ self.showTime()
+ self.normalTimer = self.startTimer( 500 )
+ self.showDateTimer = -1
+
+ def timerEvent( self, e ):
+ if e.timerId() == self.showDateTimer:
+ self.stopDate()
+ else:
+ if self.showDateTimer == -1:
+ self.showTime()
+
+ def mousePressEvent( self, e ):
+ if e.button() == TQt.LeftButton:
+ self.showDate()
+
+ def showDate( self ):
+ if self.showDateTimer != -1:
+ return
+ d = TQDate.currentDate()
+ self.display('%2d %2d' % (d.month(), d.day()))
+ self.showDateTimer = self.startTimer(2000)
+
+ def stopDate( self ):
+ self.killTimer(self.showDateTimer)
+ self.showDateTimer = -1
+ self.showTime()
+
+ def showTime( self ):
+ self.showingColon = not self.showingColon
+ s = list(str(TQTime.currentTime().toString())[:5]) #.left(5)
+ if not self.showingColon:
+ s[2] = ' '
+ if s[0] == '0':
+ s[0] = ' '
+ s = ''.join(s)
+ self.display( s )
+
+ def TQMIN( x, y ):
+ if y > x:
+ return y
+ return x
+
+TRUE = 1
+FALSE = 0
+MOVIEFILENAME = "trolltech.gif"
+
+#
+# WidgetView contains lots of TQt widgets.
+#
+
+class WidgetView ( TQWidget ):
+ def __init__( self, *args ):
+ TQWidget.__init__(*(self,) + args)
+
+ # Set the window caption/title
+ self.setCaption( "TQt Widgets Demo Application" )
+
+ # Install an application-global event filter
+ tqApp.installEventFilter( self )
+
+ # Create a layout to position the widgets
+ self.topLayout = TQVBoxLayout( self, 10 )
+
+ # Create a grid layout to hold most of the widgets
+ self.grid = TQGridLayout( 6, 3 )
+
+ # This layout will get all of the stretch
+ self.topLayout.addLayout( self.grid, 10 )
+
+ # Create a menubar
+ self.menubar = TQMenuBar( self )
+ self.menubar.setSeparator( TQMenuBar.InWindowsStyle )
+
+ # Create an easter egg
+ TQToolTip.add( self.menubar, TQRect( 0, 0, 2, 2 ), "easter egg" )
+
+ self.popup = TQPopupMenu()
+ self.id = self.popup.insertItem( "&New" )
+ self.popup.setItemEnabled( self.id, FALSE )
+ self.id = self.popup.insertItem( "&Open" )
+ self.popup.setItemEnabled( self.id, FALSE )
+ self.popup.insertSeparator()
+ self.popup.insertItem( "&Quit", tqApp, SLOT("quit()"), TQt.CTRL+TQt.Key_Q )
+
+ self.menubar.insertItem( "&File", self.popup )
+
+ # Must tell the layout about a menubar in a widget
+ self.topLayout.setMenuBar( self.menubar )
+
+ # Create an analog and a digital clock
+ self.aclock = AnalogClock( self )
+ self.aclock.resize( 50, 50 )
+ self.dclock = DigitalClock( self )
+ self.dclock.setMaximumWidth( 200 )
+ self.grid.addWidget( self.aclock, 0, 2 )
+ self.grid.addWidget( self.dclock, 1, 2 )
+
+ # Give the dclock widget a blue palette
+ col = TQColor()
+ col.setRgb( 0xaa, 0xbe, 0xff )
+ self.dclock.setPalette( TQPalette( col ) )
+
+ # make tool tips for both of them
+ TQToolTip.add( self.aclock, "custom widget: analog clock" )
+ TQToolTip.add( self.dclock, "custom widget: digital clock" )
+
+ # Create a push button.
+ self.pb = TQPushButton( self, "button1" ) # create button 1
+ self.pb.setText( "Push button 1" )
+ self.pb.setFixedHeight( self.pb.sizeHint().height() )
+ self.grid.addWidget( self.pb, 0, 0, TQt.AlignVCenter )
+ self.connect( self.pb, SIGNAL("clicked()"), self.button1Clicked )
+ TQToolTip.add( self.pb, "push button 1" )
+ self.pm = TQPixmap()
+ self.pix = self.pm.load( "qt.png" ) # load pixmap for button 2
+ if not self.pix:
+ TQMessageBox.information( None, "TQt Widgets Example",
+ "Could not load the file \"qt.png\", which\n"
+ "contains an icon used...\n\n"
+ "The text \"line 42\" will be substituted.",
+ TQMessageBox.Ok + TQMessageBox.Default )
+
+ # Create a label containing a TQMovie
+ self.movielabel = TQLabel( self, "label0" )
+ self.movie = TQMovie( MOVIEFILENAME )
+ self.movie.connectStatus( self.movieStatus )
+ self.movie.connectUpdate( self.movieUpdate )
+ self.movielabel.setFrameStyle( TQFrame.Box | TQFrame.Plain )
+ self.movielabel.setMovie( self.movie )
+ self.movielabel.setMargin( 0 )
+ self.movielabel.setFixedSize( 128 + self.movielabel.frameWidth() * 2,
+ 64 + self.movielabel.frameWidth() * 2 )
+ self.grid.addWidget( self.movielabel, 0, 1, TQt.AlignCenter )
+ TQToolTip.add( self.movielabel, "movie" )
+
+ # Create a group of check boxes
+ self.bg = TQButtonGroup( self, "checkGroup" )
+ self.bg.setTitle( "Check Boxes" )
+ self.grid.addWidget( self.bg, 1, 0 )
+
+ # Create a layout for the check boxes
+ self.vbox = TQVBoxLayout(self.bg, 10)
+
+ self.vbox.addSpacing( self.bg.fontMetrics().height() )
+
+ self.cb = list(range(3))
+ self.cb[0] = TQCheckBox( self.bg )
+ self.cb[0].setText( "Read" )
+ self.vbox.addWidget( self.cb[0] )
+ self.cb[0].setMinimumSize( self.cb[0].sizeHint() )
+ self.cb[1] = TQCheckBox( self.bg )
+ self.cb[1].setText( "Write" )
+ self.vbox.addWidget( self.cb[1] )
+ self.cb[1].setMinimumSize( self.cb[1].sizeHint() )
+ self.cb[2] = TQCheckBox( self.bg )
+ self.cb[2].setText( "Execute" )
+ self.cb[2].setMinimumSize( self.cb[2].sizeHint() )
+ self.vbox.addWidget( self.cb[2] )
+ self.bg.setMinimumSize( self.bg.childrenRect().size() )
+ self.vbox.activate()
+
+ self.connect( self.bg, SIGNAL("clicked(int)"), self.checkBoxClicked )
+
+ TQToolTip.add( self.cb[0], "check box 1" )
+ TQToolTip.add( self.cb[1], "check box 2" )
+ TQToolTip.add( self.cb[2], "check box 3" )
+
+ # Create a group of radio buttons
+ self.bg = TQButtonGroup( self, "radioGroup" )
+ self.bg.setTitle( "Radio buttons" )
+
+ self.grid.addWidget( self.bg, 1, 1 )
+
+ # Create a layout for the radio buttons
+ self.vbox = TQVBoxLayout( self.bg, 10 )
+
+ self.vbox.addSpacing( self.bg.fontMetrics().height() )
+ self.rb = TQRadioButton( self.bg )
+ self.rb.setText( "&AM" )
+ self.rb.setChecked( TRUE )
+ self.vbox.addWidget( self.rb )
+ self.rb.setMinimumSize( self.rb.sizeHint() )
+ TQToolTip.add( self.rb, "radio button 1" )
+ self.rb = TQRadioButton( self.bg )
+ self.rb.setText( "&FM" )
+ self.vbox.addWidget( self.rb )
+ self.rb.setMinimumSize( self.rb.sizeHint() )
+ TQToolTip.add( self.rb, "radio button 2" )
+ self.rb = TQRadioButton( self.bg )
+ self.rb.setText( "&Short Wave" )
+ self.vbox.addWidget( self.rb )
+ self.rb.setMinimumSize( self.rb.sizeHint() )
+ self.vbox.activate()
+
+ self.connect( self.bg, SIGNAL("clicked(int)"), self.radioButtonClicked )
+ TQToolTip.add( self.rb, "radio button 3" )
+
+ # Create a list box
+ self.lb = TQListBox( self, "listBox" )
+ for i in range( 0, 100, 1 ): # fill list box
+ txt = TQString()
+ txt = "line %d" % i
+ if i == 42 and self.pix:
+ self.lb.insertItem( self.pm )
+ else:
+ self.lb.insertItem( txt )
+
+ self.grid.addMultiCellWidget( self.lb, 2, 4, 0, 0 )
+ self.connect( self.lb, SIGNAL("selected(int)"), self.listBoxItemSelected )
+ TQToolTip.add( self.lb, "list box" )
+
+ self.vbox = TQVBoxLayout( 8 )
+ self.grid.addLayout( self.vbox, 2, 1 )
+
+ # Create a slider
+ self.sb = TQSlider( 0, 300, 1, 100, TQSlider.Horizontal, self, "Slider" )
+ self.sb.setTickmarks( TQSlider.Below )
+ self.sb.setTickInterval( 10 )
+ self.sb.setFocusPolicy( TQWidget.TabFocus )
+ self.sb.setFixedHeight( self.sb.sizeHint().height() )
+ self.vbox.addWidget( self.sb )
+
+ self.connect( self.sb, SIGNAL("valueChanged(int)"), self.sliderValueChanged )
+ TQToolTip.add( self.sb, "slider" )
+
+ # Create a combo box
+ self.combo = TQComboBox( FALSE, self, "comboBox" )
+ self.combo.insertItem( "darkBlue" )
+ self.combo.insertItem( "darkRed" )
+ self.combo.insertItem( "darkGreen" )
+ self.combo.insertItem( "blue" )
+ self.combo.insertItem( "red" )
+ self.combo.setFixedHeight( self.combo.sizeHint().height() )
+ self.vbox.addWidget( self.combo )
+ self.connect( self.combo, SIGNAL("activated(int)"), self.comboBoxItemActivated )
+ TQToolTip.add( self.combo, "read-only combo box" )
+
+ # Create an editable combo box
+ self.edCombo = TQComboBox( TRUE, self, "edComboBox" )
+ self.edCombo.insertItem( "Permutable" )
+ self.edCombo.insertItem( "Malleable" )
+ self.edCombo.insertItem( "Adaptable" )
+ self.edCombo.insertItem( "Alterable" )
+ self.edCombo.insertItem( "Inconstant" )
+ self.edCombo.setFixedHeight( self.edCombo.sizeHint().height() )
+ self.vbox.addWidget( self.edCombo )
+ self.connect( self.edCombo, SIGNAL("activated(const TQString &)"), self.edComboBoxItemActivated)
+ TQToolTip.add( self.edCombo, "editable combo box" )
+
+ self.edCombo.setAutoCompletion( TRUE )
+
+ self.vbox.addStretch( 1 )
+
+ self.vbox = TQVBoxLayout( 8 )
+ self.grid.addLayout( self.vbox, 2, 2 )
+
+ # Create a spin box
+ self.spin = TQSpinBox( 0, 10, 1, self, "spin" )
+ self.spin.setSuffix( " mm" )
+ self.spin.setSpecialValueText( "Auto" )
+ self.spin.setMinimumSize( self.spin.sizeHint() )
+ self.connect( self.spin, SIGNAL( "valueChanged(const TQString &)" ), self.spinBoxValueChanged )
+ TQToolTip.add( self.spin, "spin box" )
+ self.vbox.addWidget( self.spin )
+
+ self.vbox.addStretch( 1 )
+
+ # Create a multi line edit
+ self.mle = TQMultiLineEdit( self, "multiLineEdit" )
+
+ self.grid.addMultiCellWidget( self.mle, 3, 3, 1, 2 )
+ self.mle.setMinimumHeight( self.mle.fontMetrics().height() * 3 )
+ self.mle.setText("This is a TQMultiLineEdit widget,\n"
+ "useful for small multi-line\n"
+ "input fields.")
+ TQToolTip.add( self.mle, "multi line editor" )
+
+ # Create a single line edit
+ self.le = TQLineEdit( self, "lineEdit" )
+ self.grid.addMultiCellWidget( self.le, 4, 4, 1, 2 )
+ self.le.setFixedHeight( self.le.sizeHint().height() )
+ self.connect( self.le, SIGNAL("textChanged(const TQString &)"), self.lineEditTextChanged )
+ TQToolTip.add( self.le, "single line editor" )
+
+ # Create a horizontal line (sort of TQFrame) above the message line
+ self.separator = TQFrame( self, "separatorLine" )
+ self.separator.setFrameStyle( TQFrame.HLine | TQFrame.Sunken )
+ self.separator.setFixedHeight( self.separator.sizeHint().height() )
+ self.grid.addMultiCellWidget( self.separator, 5, 5, 0, 2 )
+ TQToolTip.add( self.separator, "tool tips on a separator! wow!" )
+
+ self.grid.setRowStretch( 0, 0 )
+ self.grid.setRowStretch( 1, 0 )
+ self.grid.setRowStretch( 2, 0 )
+ self.grid.setRowStretch( 3, 1 )
+ self.grid.setRowStretch( 4, 1 )
+ self.grid.setRowStretch( 5, 0 )
+
+ self.grid.setColStretch( 0, 1 )
+ self.grid.setColStretch( 1, 1 )
+ self.grid.setColStretch( 2, 1 )
+
+ # Create an label and a message in a plain widget
+ # The message is updated when buttons are clicked etc.
+
+ self.hbox = TQHBoxLayout()
+ self.topLayout.addLayout( self.hbox )
+ self.msgLabel = TQLabel( self, "msgLabel" )
+ self.msgLabel.setText( "Message:" )
+ self.msgLabel.setAlignment( TQt.AlignHCenter | TQt.AlignVCenter )
+ self.msgLabel.setFixedSize( self.msgLabel.sizeHint() )
+ self.hbox.addWidget( self.msgLabel )
+ TQToolTip.add( self.msgLabel, "label 1" )
+
+ self.msg = TQLabel( self, "message" )
+ self.msg.setFrameStyle( TQFrame.Panel | TQFrame.Sunken )
+ self.msg.setAlignment( TQt.AlignCenter )
+ self.msg.setFont( TQFont( "times", 12, TQFont.Bold ) )
+ self.msg.setText( "Message" )
+ self.msg.setFixedHeight( self.msg.sizeHint().height() )
+ self.msg.setText( "" )
+ self.hbox.addWidget( self.msg, 5 )
+ TQToolTip.add( self.msg, "label 2" )
+
+ self.topLayout.activate()
+
+ def setStatus(self, text):
+ self.msg.setText( text )
+
+ def movieUpdate( self, r ):
+ # Uncomment this to test animated icons on your window manager
+ self.setIcon( self.movie.framePixmap() )
+
+ def movieStatus( self, s ):
+ if s == TQMovie.SourceEmpty or s == TQMovie.UnrecognizedFormat:
+ pm = TQPixmap('tt-logo.png')
+ self.movielabel.setPixmap(pm)
+ self.movielabel.setFixedSize(pm.size())
+ else:
+ if ( self.movielabel.movie() ): # for flicker-free animation:
+ self.movielabel.setBackgroundMode( TQWidget.NoBackground )
+
+ def button1Clicked( self ):
+ self.msg.setText( "The first push button was clicked" )
+
+ def checkBoxClicked( self, id ):
+ txt = "Check box %s clicked : " % str(id)
+ chk = ["-","-","-"]
+ if self.cb[0].isChecked():
+ chk[0] = "r"
+ if self.cb[1].isChecked():
+ chk[1] = "w"
+ if self.cb[2].isChecked():
+ chk[2] = "x"
+ txt = txt + str(chk[0]+chk[1]+chk[2])
+ self.msg.setText( txt )
+
+ def edComboBoxItemActivated( self, text):
+ self.msg.setText( "Editable Combo Box set to %s" % text )
+
+ def radioButtonClicked( self, id ):
+ self.msg.setText( "Radio button #%d clicked" % id )
+
+ def listBoxItemSelected( self, index ):
+ self.msg.setText( "List box item %d selected" % index )
+
+ def sliderValueChanged( self, value ):
+ self.msg.setText( "Movie set to %d%% of normal speed" % value )
+ self.movie.setSpeed( value )
+
+ def comboBoxItemActivated( self, index ):
+ self.msg.setText( "Combo box item %d activated" % index )
+ p = TQApplication.palette()
+ if index == 0:
+ p.setColor( TQColorGroup.Highlight, TQt.darkBlue )
+ elif index == 1:
+ p.setColor( TQColorGroup.Highlight, TQt.darkRed )
+ elif index == 2:
+ p.setColor( TQColorGroup.Highlight, TQt.darkGreen )
+ elif index == 3:
+ p.setColor( TQColorGroup.Highlight, TQt.blue )
+ elif index == 4:
+ p.setColor( TQColorGroup.Highlight, TQt.red )
+ TQApplication.setPalette( p, TRUE )
+
+ def lineEditTextChanged( self, newText ):
+ self.msg.setText("Line edit text: " + str(newText))
+
+ def spinBoxValueChanged( self, valueText ):
+ self.msg.setText("Spin box value: " + str(valueText))
+
+ # All application events are passed throught this event filter.
+ # We're using it to display some information about a clicked
+ # widget (right mouse button + CTRL).
+ #def eventFilter( self, event ):
+ # identify_now = TRUE
+ # if event.type() == Event_MouseButtonPress and identify_now:
+ # e = TQMouseEvent( event )
+ # if (e.button() == TQt.RightButton) and (e.state() & TQt.ControlButton) != 0:
+ # txt = TQString( "The clicked widget is a\n" )
+ # txt = txt + TQObect.className()
+ # txt = txt + "\nThe widget's name is\n"
+ # if TQObject.name():
+ # txt = txt + TQObject.name()
+ # else:
+ # txt = txt + "<no name>"
+ # identify_now = FALSE # don't do it in message box
+ # TQMessageBox.message( "Identify Widget", txt, 0, TQObject )
+ # identify_now = TRUE; # allow it again
+ # return FALSE # don't eat event
+
+################################################################################################
+
+#TQApplication.setColourSpec( TQApplication.CustomColor )
+a = TQApplication( sys.argv )
+
+w = WidgetView()
+a.setMainWidget( w )
+w.show()
+a.exec_loop()