Zimmer Posted March 16, 2009 Share Posted March 16, 2009 I have been learning and writing python applications for awhile now and over time have tried to learn a GUI toolkit. Having tried several I have always ended up confused, bewildered, and frustrated. Is it just me, is it that python isn't meant for GUIs? I would like to here your thoughts. Am I just someone doomed to command line applications? Should I try a new language for creating GUIs? Has anyone else had this type of problem (trying to create GUI programs)? Thanks for you input. Quote Link to comment Share on other sites More sharing options...
SomethingToChatWith Posted March 16, 2009 Share Posted March 16, 2009 Well there's always Visual Studio with Windows forms applications and toolbox with drag and drop form controls. Though with your experience with python I doubt you'd want to learn how to program for Windows only. Anyone else got a better idea? I'm actually interested myself in this. Something like VS that could be used to develop cross-platform applications. Quote Link to comment Share on other sites More sharing options...
Zimmer Posted March 16, 2009 Author Share Posted March 16, 2009 Thanks for the reply I have actually been thinking about maybe C++ but I doubt that would be any easier for GUI's. Then again I could still use python and just you VB as a shell hmm. The reply is much appreciated. Quote Link to comment Share on other sites More sharing options...
SomethingToChatWith Posted March 16, 2009 Share Posted March 16, 2009 If you program with C++.Net in VS than yes it is. Spend maybe 30 minutes or so on the GUI and the rest of your efforts go towards coding the actual use for the app. Like I said, its drag and drop. Grab a button, put it on the form. Double-click the button and start typing the code for it... Quote Link to comment Share on other sites More sharing options...
Zimmer Posted March 16, 2009 Author Share Posted March 16, 2009 Thanks so much for all the replys. Is it same on free version? Would the program have .Net dependencies? Is it same old C++ or a Microsoft modified version? Thanks again for the replys. Quote Link to comment Share on other sites More sharing options...
Sparda Posted March 16, 2009 Share Posted March 16, 2009 Writing a GUI in Java is more than easy: import javax.swing.jframe; import javax.swing.jbutton; public void magicFrame() { jframe tehFrame = new jframe("Window in Java"); tehFrame.add(new jbutton("This is a button")); tehFrame.pack(); tehFrame.setvisible(true); } Some thing like that? Makes a window that has a button inside it. Quote Link to comment Share on other sites More sharing options...
Jonnycake Posted March 16, 2009 Share Posted March 16, 2009 Check out tkinter, from what I remember when I was using it it was quite easy to learn. I haven't used it in so long though - don't do very much GUI programming. from Tkinter import * root=Tk() myString=StringVar() Label(root,textvariable=myString).pack() myString.set("Well, eh, how about a little red Leicester.") def changeLabel(): myString.set("I'm, a-fraid we're fresh out of red Leicester, sir. ") Button(root,text='Click Me',command=changeLabel).pack() root.mainloop() Source Quote Link to comment Share on other sites More sharing options...
ratmandall Posted March 16, 2009 Share Posted March 16, 2009 Have you tried gtk? It always seemed like the easiest to me. Here's a simple window with a kill function so the program exits properly when the window is closed. import gtk, sys def gtkwindow(): def kill(window): window.destroy() sys.exit() window = gtk.Window() width, height = 250,200 window.resize(width, height) window.show() window.connect('destroy',kill) gtk.main() gtkwindow() Quote Link to comment Share on other sites More sharing options...
Zimmer Posted March 16, 2009 Author Share Posted March 16, 2009 thanks for the suggestions. ratmandall where did you learn gtk+? Is it the same as pygtk? and if so all the tutorials I've found use classes and yours doesn't can you still make more than a simple gui with it? Quote Link to comment Share on other sites More sharing options...
Zimmer Posted March 16, 2009 Author Share Posted March 16, 2009 thanks for the suggestions. ratmandall where did you learn gtk+? Is it the same as pygtk? and if so all the tutorials I've found use classes and yours doesn't can you still make more than a simple gui with it? Quote Link to comment Share on other sites More sharing options...
Mike Bond Posted March 17, 2009 Share Posted March 17, 2009 I agree with [ratmandall], gtk is definitely the way to go. You should also check into Glade, it can build an XML file that describes your GUI and that gets loaded at runtime. #!/usr/bin/env python import sys try: import pygtk pygtk.require("2.0") except: pass try: import gtk import gtk.glade except: sys.exit(1) class pyGUI: """ Main class for pyGUI application """ def __init__(self): self.wTree = gtk.glade.XML("dialog.glade") # Build our dictionary and connect it dic = { "on_ButtonClose_clicked": self.ActionClose, "on_DialogMain_destroy": gtk.main_quit } self.wTree.signal_autoconnect(dic) def ActionClose(self, widget): gtk.main_quit() if __name__ == '__main__': app = pyGUI() gtk.main() I have been learning and writing python applications for awhile now and over time have tried to learn a GUI toolkit. Having tried several I have always ended up confused, bewildered, and frustrated. Is it just me, is it that python isn't meant for GUIs? I would like to here your thoughts. Am I just someone doomed to command line applications? Should I try a new language for creating GUIs? Has anyone else had this type of problem (trying to create GUI programs)? Thanks for you input. Quote Link to comment Share on other sites More sharing options...
Zimmer Posted March 17, 2009 Author Share Posted March 17, 2009 Right know I'm trying to decide whether to use GTK and Glade or Visual C++ (would require learning new language but that might help me with getting concepts in programming I don't get but everyone else does :)) Quote Link to comment Share on other sites More sharing options...
Destro Posted March 18, 2009 Share Posted March 18, 2009 I have not been coding in python for long, but my friend has and I asked him about your question. He said that python is more of a command line language. The most gui you will get out of it is if compile it and stuff like that in programs like xcode. Well, good luck with your gui. cheers, Destro Quote Link to comment Share on other sites More sharing options...
shawty Posted March 18, 2009 Share Posted March 18, 2009 Writing a GUI in Java is more than easy: import javax.swing.jframe; import javax.swing.jbutton; public void magicFrame() { jframe tehFrame = new jframe("Window in Java"); tehFrame.add(new jbutton("This is a button")); tehFrame.pack(); tehFrame.setvisible(true); } Some thing like that? Makes a window that has a button inside it. And for a free IDE, try Netbeans. WHich can be set up to work with PHP/Python/C/C++ etc etc, but specialises in java. As for pyton being no use for GUI, i'd have to say use WxWindows. For an example of what can be achived, just take a look at a program featured on the show. Inkscape. Inkscape was written in Python using the WxWindows toolkit. Cheers Shawty Quote Link to comment Share on other sites More sharing options...
Zimmer Posted March 18, 2009 Author Share Posted March 18, 2009 @Destro Thanks for that, I believe I heard that from somewhere but hearing it from a second source helps. Shawty ya I'll probably look into java or VB, VB C++, or VB C#. It seems that I can easily integrate the command line python apps by compiling the exe with a .pyw extensions so their are no black boxes to free users out. Also for python I can just return the data using sys.exit(i) and have the gui use it. Also thanks everyone for giving you insights, help, and experience it is much appreciated. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.