|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming | |
Tutorial: Using Python/Glade to create a simple GUI application.
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#11 (permalink) | |||||||||||||
|
The Game
![]() |
Too true. ICT is a course in being a receptionist. It's a joke.
This thread had been here for ages, then it suddenly gets active out of nowhere XD
__________________
Lattyware | Main (Sig) Rig: gBOX42 | Lan Rig: gLAN42 Never been convinced by Linux? Here is a challenge. | Using LVM Scratched Disc? | Guide To LAN Parties | Writing a GUI application in Python/Glade Etching an image into your case. | Wireless Access Points: Easy wireless networking. A Member Of The OCN Anime/Manga Club "I disapprove of what you say, but I will defend to the death your right to say it." --Evelyn Beatrice Hall
|
|||||||||||||
|
|
|
|
#12 (permalink) | |||||||||||||
|
Luck : 10pts
![]() |
You know it took me a month after i first started to notice that.
Hey Latty, might want to ask BFRD about getting this stickied.
__________________
|
|||||||||||||
|
|
|
|
#13 (permalink) | |||||||||||||
|
The Game
![]() |
You think it's sticky-worthy?
__________________
Lattyware | Main (Sig) Rig: gBOX42 | Lan Rig: gLAN42 Never been convinced by Linux? Here is a challenge. | Using LVM Scratched Disc? | Guide To LAN Parties | Writing a GUI application in Python/Glade Etching an image into your case. | Wireless Access Points: Easy wireless networking. A Member Of The OCN Anime/Manga Club "I disapprove of what you say, but I will defend to the death your right to say it." --Evelyn Beatrice Hall
|
|||||||||||||
|
|
|
|
#14 (permalink) | |||||||||||||
|
Luck : 10pts
![]() |
That is for him to decide under my thoughts.
__________________
|
|||||||||||||
|
|
|
|
#16 (permalink) | ||||||||||||||
|
The Game
![]() |
Quote:
That said, this guide is getting a bit old, and Glade is being replaced with gtk.Builder - this removes the need for an extra library, and will have more features. That said, gtk.Builder needs a very new version of the GTK, so it's still not mainstream, so this is not something you should worry about right now. gtk.Builder is also largely very similar to glade. Glade will still exist as a GUI to create gtk.Builder files, and you can convert pretty easily. Changing the code should again be pretty simple.
__________________
Lattyware | Main (Sig) Rig: gBOX42 | Lan Rig: gLAN42 Never been convinced by Linux? Here is a challenge. | Using LVM Scratched Disc? | Guide To LAN Parties | Writing a GUI application in Python/Glade Etching an image into your case. | Wireless Access Points: Easy wireless networking. A Member Of The OCN Anime/Manga Club "I disapprove of what you say, but I will defend to the death your right to say it." --Evelyn Beatrice Hall
|
||||||||||||||
|
|
|
|
#17 (permalink) |
|
New to Overclock.net
|
Hello!! I'm trying to learn how to build my GUIs from your tutorial (very good, thanks). I went over all of it. After finished, I run the Python file of the GUI "tutgui.py" and got:
GTK Not Availible >>> >>> import gtk Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:\Python25\Lib\site-packages\gtk-2.0\gtk\__init__.py", line 48, in <module> ImportError: DLL load failed: The specified procedure could not be found. >>> I use Python 2.5 on Win32 xp platform, I know you use different OS. What you think I need to do/install/reinstall/add to the code/take off code... to correct this issue? If it is not matter of my system and I should specify something else in your code for it to run on my Win32?, where if so? should I use Pygtk somewhere in the codes? Please heeeeeeelp! Thanks so much, Angelica. |
|
|
|
|
|
#18 (permalink) | |||||||||||||
|
With great difficulty
![]() |
I'm guessing you need to install GTK for windows
__________________
|
|||||||||||||
|
|
|
|
#19 (permalink) | |||||||||||||||
|
The Game
![]() |
Quote:
Quote:
__________________
Lattyware | Main (Sig) Rig: gBOX42 | Lan Rig: gLAN42 Never been convinced by Linux? Here is a challenge. | Using LVM Scratched Disc? | Guide To LAN Parties | Writing a GUI application in Python/Glade Etching an image into your case. | Wireless Access Points: Easy wireless networking. A Member Of The OCN Anime/Manga Club "I disapprove of what you say, but I will defend to the death your right to say it." --Evelyn Beatrice Hall
|
|||||||||||||||
|
|
|
|
#20 (permalink) |
|
New to Overclock.net
|
Hi Lattyware et al
I know this is an old thread, but it was one of the first that I came across when searching for help, and probably the best getting-started walkthrough for Glade and python. Anyway, you mention that gtk.Builder is replacing libglade, so I thought I would follow that route (starting to learn a bit of python), and after much huffing and puffing have got your adder program to work with gtkbuilder. Here's the code that works for me if anyone's interested: Code:
import sys
try:
import pygtk
pygtk.require("2.0")
except:
pass
try:
import gtk
except:
print("GTK Not Availible")
sys.exit(1)
class adder:
result = 0
def __init__( self, number1, number2 ):
self.result = int( number1 ) + int( number2 )
def giveResult( self ):
return str(self.result)
class adderGui:
wTree = gtk.Builder()
def __init__( self ):
self.builder = gtk.Builder()
self.builder.add_from_file("Adder.glade")
self.window = self.builder.get_object ("windowMain")
if self.window:
self.window.connect("destroy", gtk.main_quit)
self.entry1 = self.builder.get_object ("entry1")
self.entry2 = self.builder.get_object ("entry2")
dic = {
"on_buttonQuit_clicked" : self.quit,
"on_buttonAdd_clicked" : self.add,
"on_windowMain_destroy" : self.quit,
}
self.builder.connect_signals( dic )
def add(self, widget):
entry1 = self.builder.get_object ("entry1")
entry2 = self.builder.get_object ("entry2")
try:
thistime = adder( entry1.get_text(), entry2.get_text() )
except ValueError:
self.builder.get_object("hboxWarning").show()
self.builder.get_object("image1").show()
self.builder.get_object("entryResult").set_text("ERROR")
return 0
self.builder.get_object("hboxWarning").hide()
self.builder.get_object("image1").hide()
self.builder.get_object("entryResult").set_text(thistime.giveResult())
def quit(self, widget):
sys.exit(0)
adderGui = adderGui()
adderGui.window.show()
gtk.main()
Cheers Charlie Last edited by FokkerCharlie : 08-24-09 at 03:15 AM |
|
|
|
![]() |
| Tags |
| glade, gui, programming, python, tutorial |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|