[python-win32] Win32 GUI for beginners.
Heang Lim
heang.s.lim at gmail.com
Tue Dec 31 19:26:22 CET 2013
Hi Sean,
I have been using Qt to automate test cases for the different network
security applications and Voice over IP products I used to work on for my
current company and my last company for the last ten years. I have built a
couple GUI apps using both Qt (PyQt4) and Python scripts for these two
companies to run automated tests from the GUI drop-down menus, text boxes,
buttons, etc. that I designed using Qt 4 Designer. Qt 4 Designer supports
all the various GUI components you mentioned above and more, and you can
design it the way you wanted. I recommend using Qt 4 Designer. A few
pointers to learn Qt/Qt 4 Designer:
1. Use Qt 4 Designer to design your GUI to start of instead of trying to
write the code yourself. Begin by creating a a button, for instance, and
keep building and adding more GUI widgets as you go, and save into a file
let's called guiApp.ui. Use pyuic4 batch file to compile and convert your
widget file into Python code: pyuic4 guiApp.ui -o guiApp.py
2. When you convert your guiApp.ui into guiApp.py, it creates a Python
class (e.g Ui_Test_Automation for my apps) with widget objects you need to
call to trigger widget actions/signals. You will need to look into
guiApp.py Python script to learn to use the objects it creates for various
widgets/buttons, drop-down menu, etc. For instance, if you create a push
button called RUN_TESTS, pyuic4 will create something like the following:
class Ui_Test_Automation(object):
def setupUi(self, Test_Automation):
self.RUN_TESTS=QtGui.QPushButton(Test_Automation)
....
(Google this part as each widget has different actions.signals it can
perform)
3. For my GUI apps I created, I have another Python script to import
guiApp file I created from step 1 above as follows to run my tests:
from guiApp import Ui_Test_Automation
4. When I need to trigger an action for the RUN_TESTS button, the code for
that looks something like this:
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Test_Automation()
QtCore.QObject.connect(self.ui.RUN_TESTS, QtCore.SIGNAL("clicked()"),
self.RUN_SELECTED_TESTS)
...
def RUN_SELECTED_TESTS():
#This method will run all selected tests on the GUI.
5. Google for sample Qt scripts and how to use and trigger Qt button
signals. There are a lot of sample codes out there.
I hope this helps.
Heang Lim
On Tue, Dec 31, 2013 at 9:47 AM, John Grant <cyrfer at gmail.com> wrote:
> Hi Sean,
> My opinion is that you would be better served learning Qt. In some ways
> this additional dependency might cloud matters, but for the features you
> ask for, Qt will make your development streamlined. You can find more
> information about the Python bindings at:
> https://wiki.python.org/moin/PyQt
>
> Good luck,
> John
> On Dec 31, 2013 3:11 AM, "Sean Murphy" <mhysnq1964 at icloud.com> wrote:
>
>> Hi all.
>>
>> I am very very new to Python. I have read the book on programming for
>> Windows with Python that was released in 2000. The book is very good but
>> doesn't give me the basic information I am seeking. Since I am a beginner
>> programmer.
>>
>> I want to create a GUI windows app with Python. The program has to use
>> default Windows 32 or 64 bit objects. I wish to get the following
>> components:
>>
>> Menu bar
>> Listview
>> Treeview
>> Richedit or a multiline edit field
>> A couple of buttons.
>> All objects must be able to be access by the keyboard. either via tab
>> stops (using the tab or shift tab key) and short cut keys.
>>
>>
>> I have a 70 mb text file that is marked up using YML. I wish to show each
>> section in the edit field. The list view shows the name of each item. The
>> tree view will contain categories.
>>
>> I have seen PYGUI which I am not sure if it is easier then using the MSF
>> approach which the book above mentions.
>>
>> So I really need assistance to progress this home bobbie project to
>> expand my programming skills. Any wikis, documentations, good code examples
>> with explanations, etc I would love to get my hands on.
>>
>> I am reading about 3 or 4 books on Python to get up to speed. But only
>> found one book on Win32 programming. I do not want to have to turn around
>> and learn win32 or MFC. If I have to then please point me towards a good
>> book or resource.
>>
>>
>> Regards
>> Sean
>> _______________________________________________
>> python-win32 mailing list
>> python-win32 at python.org
>> https://mail.python.org/mailman/listinfo/python-win32
>>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20131231/dfdf0237/attachment-0001.html>
More information about the python-win32
mailing list