Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 08-24-09   #21 (permalink)
The Game
 
lattyware's Avatar
 
intel nvidia

Join Date: Feb 2007
Location: In A Faraday Cage
Posts: 2,678

Rep: 280 lattyware is a proven memberlattyware is a proven memberlattyware is a proven member
Unique Rep: 206
Folding Team Rank: 534
Hardware Reviews: 1
Trader Rating: 0
Default

Quote:
Originally Posted by FokkerCharlie View Post
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()
I daresay that it could be tidier or bettered in many ways (pointers welcome). Any suggestions as to where to go next?

Cheers
Charlie
Good job. As to where to go next, I'd suggest thinking up a small project, something that you want, and create it. There are lots of very small, simple apps out there, just try making something, get into the flow of thinking about how to do something.

And whenever you are writing python, always have the reference open. Python has great docs, and having them open can really help. No one will remember all the features on offer.
__________________
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

System: gBOX42
CPU
Core 2 Duo E6600 @ 3.51GHz
Motherboard
Asus P5B Deluxe/WiFi-AP
Memory
2 x OCZ DDR2 Platinum 1Gb PC6400 C4
Graphics Card
256MB MSI 8600GTS
Hard Drive
2x 1TB SATA, 2 x 500GB SATA
Sound Card
Creative Soundblaster Audigy SE
Power Supply
SEASONIC S12-600
Case
CoolerMaster Cosmos
CPU cooling
XSPC X2O Delta CPU Waterblock V2
GPU cooling
D-Tek FuZion GFX Block
OS
Arch Linux x64
Monitor
Dell 2407WFP, Dell E248WFP
lattyware is offline I fold for Overclock.net Overclocked Account lattyware's Gallery   Reply With Quote
Old 09-27-09   #22 (permalink)
The Game
 
lattyware's Avatar
 
intel nvidia

Join Date: Feb 2007
Location: In A Faraday Cage
Posts: 2,678

Rep: 280 lattyware is a proven memberlattyware is a proven memberlattyware is a proven member
Unique Rep: 206
Folding Team Rank: 534
Hardware Reviews: 1
Trader Rating: 0
Default

Update: I recorded a screencast of this tutorial and uploaded to youtube, so if you want an in-depth, complete version of this, then do feel free to watch it.
__________________
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

System: gBOX42
CPU
Core 2 Duo E6600 @ 3.51GHz
Motherboard
Asus P5B Deluxe/WiFi-AP
Memory
2 x OCZ DDR2 Platinum 1Gb PC6400 C4
Graphics Card
256MB MSI 8600GTS
Hard Drive
2x 1TB SATA, 2 x 500GB SATA
Sound Card
Creative Soundblaster Audigy SE
Power Supply
SEASONIC S12-600
Case
CoolerMaster Cosmos
CPU cooling
XSPC X2O Delta CPU Waterblock V2
GPU cooling
D-Tek FuZion GFX Block
OS
Arch Linux x64
Monitor
Dell 2407WFP, Dell E248WFP
lattyware is offline I fold for Overclock.net Overclocked Account lattyware's Gallery   Reply With Quote
Old 09-27-09   #23 (permalink)
PC Gamer
 
chemicalfan's Avatar
 
intel ati

Join Date: May 2008
Location: Portsmouth, UK
Posts: 1,378
Blog Entries: 3

Rep: 116 chemicalfan is acknowledged by manychemicalfan is acknowledged by many
Unique Rep: 90
Trader Rating: 0
Default

Cheers Latty, will check this out later - I've just got onto GUI programming in Python using wXwidgets, so this will be really handy! My initial opinions, are that GUI programming in Python is a pain in the ass as it requires a lot of code for not a lot of benefit, and that a decent Python IDE which handled the backend coding of the GUI would be an absolute godsend!!!
__________________
Intel Processor Finder - essential knowledge for OC'ers
OCCT - essential tool for OC'ers
Quote:
Originally Posted by Inuyasha1771
I hate it when they are like " LET'S WATCH A MOVIE >=3" and you're like "No, it's 6 PM, I just got off work, I need to overclock." and they can't relate. Give me a girl who overclocks, and I'll give you a miracle.

System: Black 'n' blue II
CPU
Core i7 860
Motherboard
MSI P55-GD60
Memory
4GB G.Skill Ripjaw
Graphics Card
Xpertvision Radeon HD4850
Hard Drive
150Gb Velociraptor & 250Gb Samsung
Sound Card
ESI Maya USB
Power Supply
Thermaltake Purepower RX 550
Case
Galaxy II
CPU cooling
Noctua NH-U12P SE2
GPU cooling
Stock
OS
Vista Home Premium x64
Monitor
Hyundai BlueH H224W 22" LCD
chemicalfan is online now   Reply With Quote
Old 10-01-09   #24 (permalink)
The Game
 
lattyware's Avatar
 
intel nvidia

Join Date: Feb 2007
Location: In A Faraday Cage
Posts: 2,678

Rep: 280 lattyware is a proven memberlattyware is a proven memberlattyware is a proven member
Unique Rep: 206
Folding Team Rank: 534
Hardware Reviews: 1
Trader Rating: 0
Default

Quote:
Originally Posted by chemicalfan View Post
Cheers Latty, will check this out later - I've just got onto GUI programming in Python using wXwidgets, so this will be really handy! My initial opinions, are that GUI programming in Python is a pain in the ass as it requires a lot of code for not a lot of benefit, and that a decent Python IDE which handled the backend coding of the GUI would be an absolute godsend!!!
I find it works out pretty well actually. To reduce code you can skip using a dictionary of signals and associating them, and use the autoconnect function by passing it a class, and it'll automatically add up functions with the name of the signal.
__________________
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

System: gBOX42
CPU
Core 2 Duo E6600 @ 3.51GHz
Motherboard
Asus P5B Deluxe/WiFi-AP
Memory
2 x OCZ DDR2 Platinum 1Gb PC6400 C4
Graphics Card
256MB MSI 8600GTS
Hard Drive
2x 1TB SATA, 2 x 500GB SATA
Sound Card
Creative Soundblaster Audigy SE
Power Supply
SEASONIC S12-600
Case
CoolerMaster Cosmos
CPU cooling
XSPC X2O Delta CPU Waterblock V2
GPU cooling
D-Tek FuZion GFX Block
OS
Arch Linux x64
Monitor
Dell 2407WFP, Dell E248WFP
lattyware is offline I fold for Overclock.net Overclocked Account lattyware's Gallery   Reply With Quote
Reply

Tags
glade, gui, programming, python, tutorial


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 11:39 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.13210 seconds with 9 queries