473,586 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PyGTK : a NEW simple way to code an app

I was a fan of "SimpleGlad eApp/tepache way" to build a pygtk app.
I've build a new efficient/dynamic way to build a pygtk app ...

Here is an example :
=============== =============== =============== ====
class Fen(GladeApp):
"""
Window win
.title="Hello"
@delete_event
VBox
HBox
Label jo
.label="kokotte "
entry myEntry
.text="kuku"
gtkBuTTon b2
.label="33"
@clicked
Label jo
.label="koko"
Button b
.label="3"
@clicked
"""
def init(self,m):
self.jo.set_tex t(m)
pass
def on_b_clicked(se lf,*a):
self.quit(3)
def on_b2_clicked(s elf,*a):
self.quit(33)
def on_win_delete_e vent(self,*args ):
self.quit(4)

f=Fen("koko2")
print f.loop()
=============== =============== =============== ====

How it works :

in fact, the __doc__ is converted as a "glade file"
the tree of object is indented (like python way)
you can see some common pygtk widget ...
line starting with a dot is an property of the parent object.
line starting with a @ is a declaration of a event of the parent
object.
widgets are not case sensitive, and can start with "Gtk". If a second
word is provided it will be used as an "id", otherwise an unique id
will be build according the type of widget.
the window is created with glade, widgets are provided as attributs of
the instance, and signals are autoconnected on method
"on_[widgetId]_[event](self,*args)" (if a signal is missing in your
class, it warns you at run time) ....

It will not replace the use of glade-3 for complex widget ... but I
think it's an easy way to code very easily/quickly a simple pygtk
window/form.
I think it could be really useful/handly for beginners too.

for people which are involved in pygtk/python/gui ... i'd like to hear
your comments/ideas ...

Rq:
i don't provide the code now, but it will be released in next version
of "GladeApp" ( http://manatlan.infogami.com/GladeApp )
it works already, but i need to make "packing properties available"
too ...

May 11 '07 #1
1 1579
manatlan <ma******@gmail .comwrote:
I was a fan of "SimpleGlad eApp/tepache way" to build a pygtk app.
I've build a new efficient/dynamic way to build a pygtk app ...
Here is an example :
=============== =============== =============== ====
class Fen(GladeApp):
"""
Window win
.title="Hello"
@delete_event
VBox
HBox
Label jo
.label="kokotte "
entry myEntry
.text="kuku"
gtkBuTTon b2
.label="33"
@clicked
Label jo
.label="koko"
Button b
.label="3"
@clicked
"""
def init(self,m):
self.jo.set_tex t(m)
pass
def on_b_clicked(se lf,*a):
self.quit(3)
def on_b2_clicked(s elf,*a):
self.quit(33)
def on_win_delete_e vent(self,*args ):
self.quit(4)
f=Fen("koko2")
print f.loop()
=============== =============== =============== ====
How it works :
in fact, the __doc__ is converted as a "glade file"
the tree of object is indented (like python way)
you can see some common pygtk widget ...
line starting with a dot is an property of the parent object.
line starting with a @ is a declaration of a event of the parent
object.
widgets are not case sensitive, and can start with "Gtk". If a second
word is provided it will be used as an "id", otherwise an unique id
will be build according the type of widget.
the window is created with glade, widgets are provided as attributs of
the instance, and signals are autoconnected on method
"on_[widgetId]_[event](self,*args)" (if a signal is missing in your
class, it warns you at run time) ....
It will not replace the use of glade-3 for complex widget ... but I
think it's an easy way to code very easily/quickly a simple pygtk
window/form.
I think it could be really useful/handly for beginners too.
for people which are involved in pygtk/python/gui ... i'd like to hear
your comments/ideas ...
Rq:
i don't provide the code now, but it will be released in next version
of "GladeApp" ( http://manatlan.infogami.com/GladeApp )
it works already, but i need to make "packing properties available"
too ...
I'd be a little leery of overloading the __doc__ strings in this
way. (They are overloaded enough when used for doctest strings ...
but those can serve a legitimate documentary purpose and other doctests
can be stored separately).

Perhaps it would make sense to standardize on a defined member name
such as: GTK__Glade. The rest of your code could remain the same.

Are there any other Python projects using other "magically introspected
strings" approaches? I thought I saw something being used by some
"programmin g by contract" or some AOP (aspect oriented programming) tools
that might be using something like this.
--
Jim Dennis,
Starshine: Signed, Sealed, Delivered

Jun 10 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2592
by: Jeremy Bowers | last post by:
I have an image in the Python Image Library. I'm trying to get it into PyGTK in color. Is there any way to do this cross-platform, preferably without writing to anything to the disk? PIL apparently can't write XPMs. GTK will only take XPMs, that I can see. Therein lies the rub. I can ship over monochrome bitmaps via XBM, but I'd rather be...
22
5751
by: dcrespo | last post by:
Hi all... I think wxPython is much better than PyGTK. First of all, PyGTK needs the GTK runtime installed, whereas wxPython is entirely Python's modules, so It facilitates the apps' distribution. Also, PyGTK uses specific controls or widgets of GTK, while wxPython uses native controls of the platform where the app is running. I'm...
25
4265
by: TPJ | last post by:
GUI's etc: PyGtk on Windows "(...) So if someone develops mainly for X and just wants to make sure that it is not impossible to run on Windows, you can use PyGTK. (...)", July 2nd, 1999 pyGTK on Windows "(...) > can i use pyGTK under > Windows???
8
16709
by: JyotiC | last post by:
I want to make a stand alone gui. Whose work is to get the diff options from user and run a shell script based on them. I wanna know which one is better to use Tkinter or PyGTK, in terms of efficiency and functionality. I hv read about Tkinter, but it takes too much time to load, is there a way to make it faster. Is all gui take more...
0
1580
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first version i made, the gui would freeze after clicking the close button until pygame finished playing the sound. In Windows it was acceptable because it...
1
1768
by: krishnakant Mane | last post by:
hello, I will be writing some code in PyGTK to run on linux. but I want to know if there are any installers or distutils available for PyGTK on windows? I have heard that installing gimp or even pygtk is next to impossible and is very tedious if at all one gets success. can any one share their experiences with installing and running pygtk...
0
1395
by: He Jibo | last post by:
Hi, Everyone, Could someone help me how to install pygtk? I get some problems with it. Here is the error I get while install pygtk: https://netfiles.uiuc.edu/jibohe2/error.GIF?uniq=-k6678k I use python 2.4, I first installed glade-2.0.1-win32_with_gtk, and then pycairo-1.0.2-1.win32-py2.4, pygobject-2.12.3-1.win32-py2.4, and
2
2112
by: Dmitry Teslenko | last post by:
Hello! I have simple chat application with pygtk UI. I want some event (for example update user list) to have place every n seconds. What's the best way to archive it? I tried threading.Timer but result is following: all events wait till exit of gtk main loop and only then they occur. Thanks in advance
0
1777
by: Michael Palmer | last post by:
On Sep 16, 12:30 pm, binaryjesus <coolman.gu...@gmail.comwrote: I haven't tried it myself, but I came across a blog post the other day that describes a way of building windows installers for pyGTK applications at http://unpythonic.blogspot.com/2007/07/pygtk-py2exe-and-inno-setup-for-single.html
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.