[Tutor] wxPython parent classes
I've been noticing that in all the example codes I have seen, when someone creates container, x, inside of a frame or other container class, y, they always seem to create an instance of wx.Panel first and then use that instance as the parent class of container x. I have been just placing 'self' in there, however, letting the class I am creating (whether it be a wx.Frame subclass, wx.ScrolledWindow subclass, etc) be the parent class of any other wx.Window class I instantiate inside that class. Is one way better than the other, and if so, why? Thanks. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython parent classes
wx.Panel provides better cross-platform reliability, so it's fairly standard practice to go with a Panel in a Frame, and place the buttons, etc. on the panel. On Tue, Apr 19, 2011 at 11:59 AM, Eric Stevens element.eff...@gmail.comwrote: I've been noticing that in all the example codes I have seen, when someone creates container, x, inside of a frame or other container class, y, they always seem to create an instance of wx.Panel first and then use that instance as the parent class of container x. I have been just placing 'self' in there, however, letting the class I am creating (whether it be a wx.Frame subclass, wx.ScrolledWindow subclass, etc) be the parent class of any other wx.Window class I instantiate inside that class. Is one way better than the other, and if so, why? Thanks. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython parent classes
Eric Stevens element.eff...@gmail.com wrote I've been noticing that in all the example codes I have seen, when someone creates container, x, inside of a frame or other container class, y, they always seem to create an instance of wx.Panel first You got an answer this time, but you will probably get better results posting wxPython questions on the wxPython mailing list/forums. Posting here is more a matter of luck if anyone reading happens to use wx... Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxPython issues
I am trying to create an addressbook program and am currently working on prototype pages. Right now, I am trying to create a wx.ScrolledWindow class with a wx.ListCtrl to display the names of all contacts. I keep running into an error with my current configuration that is stating I have not specified the 'parent' position when instantiating my class, but from my best understanding, I have. (The full Exception Error is below). I have attatched a text file with a copy of my program. I am new at this, so I am sure my program is not optimal, so I would also appreciate any further advice or comments if you have the time. Thank you. Traceback (most recent call last): File C:\Python27\programming\wxPython practice, line 34, in module frame= RandomFrame(None, -1, 'Random') File C:\Python27\programming\wxPython practice, line 29, in __init__ listpage = ScrolledWindow(panel, -1) File C:\Python27\programming\wxPython practice, line 9, in __init__ wx.ScrolledWindow.__init__(self) File C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_windows.py, line 145, in __init__ _windows_.ScrolledWindow_swiginit(self,_windows_.new_ScrolledWindow(*args, **kwargs)) TypeError: Required argument 'parent' (pos 1) not found contacts program.rtf Description: RTF file ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython issues
Eric Stevens element.eff...@gmail.com wrote prototype pages. Right now, I am trying to create a wx.ScrolledWindow class I would strongly recommend not calling your class the same as the standard widget. I don't think thats causing issues here but I wouldn't be surprised! Its a bit like overrriding built-in Python functions. Users of wxPython expect ScrolledWindow to refer to the standard one... understanding, I have. (The full Exception Error is below). I have attatched a text file with a copy of my program. Being picky, you attached an RTF file which mostly won't cause a problem, but you might as well just have attached the original python code since it truly is a text file! And that way there is no chance of anything getting clipped or distorted during the cut n paste or import/conversion process File C:\Python27\programming\wxPython practice, line 34, in module frame= RandomFrame(None, -1, 'Random') File C:\Python27\programming\wxPython practice, line 29, in __init__ listpage = ScrolledWindow(panel, -1) File C:\Python27\programming\wxPython practice, line 9, in __init__ wx.ScrolledWindow.__init__(self) File C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_windows.py, line 145, in __init__ _windows_.ScrolledWindow_swiginit(self,_windows_.new_ScrolledWindow(*args, **kwargs)) TypeError: Required argument 'parent' (pos 1) not found Your code looks like: class ScrolledWindow(wx.ScrolledWindow): def __init__(self, parent, id, style = wx.LC_REPORT): wx.ScrolledWindow.__init__(self) Notice that you do not pass the parent etc onto the superclass constructor. You need something like: wx.ScrolledWindow.__init__(self, parent, id, style) HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxPython, Tkinter (was: program hangs in while loop using wx.yield
On Tue, 16 Nov 2010, Patty wrote: Hi Terry - I am an alumni of UCSC (University of California, Santa Cruz) and live really close so I can request books throughout the UC system just like you describe and there is no limit - or maybe an extremely high limit - to the number of books I can check out from McHenry Library. It is so worth paying alumni dues! There is no way they would transport books to the public library to make it easier for people though - not with the way the city and the university feel about each other :} You might be surprised. I would't have expected to get a book from San Diego State University sent to the San Jose Public Library, but it did. I just entered teh request, and a few hours later, I had anote saying it was on the way. The system finds the copy and obtains it. It's not on a one-to-one basis, i.e., as if SJPL had an arrangement with SDSU; it's more of the libraries deciding to patricipate in the pool. If I just can't figure out how to do this with Tkinter and the Python Imaging Library, is 'wxPython' the additional software I would want to install and try with? wxPython is an alternative to Tkinter. The advantage of Tkinter is that it comes as part of standard Python. You know that it will be installed on any reasonably current Python installation. If you write a program using Tkinter and send it to me, you can be sure that I can run it as long as I have Python installed (at least as far as the GUI is concerned; other things such as PIL might still be an issue). wxPython is an API over the cross-platform wxWidgets GUI. I think it provides a cleaner and more native look compared to Tkinter. For what my opinion is work (and that's not much -- I'm pretty inexperienced at GUI stuff), I find it at least as easy to use as Tkinter, but I recall a learning curve when I started. I don't use Tkinter any more, preferring wxPython, but opinions will vary. Here's a comparison of the two; it's hosted on a wxPython site, so it's undoubtedly slanted toward wxPython: http://wiki.wxpython.org/Choosing%20wxPython%20over%20Tkinter Another couple: http://www.llaisdy.com/static/tech/python/calc.html http://ojs.pythonpapers.org/index.php/tpp/article/viewArticle/61 However, if you would like an example of using Tkinter with PIL, I would be happy to provide you with a very rough program I wrote several years ago for my own use (when I still used Tkinter). It loads an image that was taken with a digital camera; reads the date the photo was taken from the image's EXIF data; adds a timestamp to the photo, and saves it. It's very rough; I have the habit of writing something only to the point where it's good enough for me, and then stop development on it. But you might find it helpful of a straightforward program that uses both. It's from about 2006 or so, and I am by no means a GUI programming expert and was even less so then, so my techniques may be suspect; but I'd be happy to send it to you for what it's worth. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxpython question
Thank you guys for the replies! And thanks for the headsup about the wxpython mail list, I'll be sure to sign up there as well. On Wed, Sep 9, 2009 at 7:14 PM, Alan Gauld alan.ga...@btinternet.comwrote: Kristina Ambert krissy.amb...@gmail.com wrote I'm not sure if I could ask questions about wx in this list or not, hopefully it's okay? If not I guess disregard this question. Yes its fine but you will get more complete answers in the wx mailing list. But, does anyone have any idea of if it's possible to make a frame that will latch on to the parent frame (e.g. if you resize the parent, the child also resizes, if you move the parent, the child also moves), aside from using the MDI window that's wxpython provides? Yes, I think so - I'm not 100% sure I know what you mean. But the standard wxPython layout managers should control all that for you. Look into the docs for FlexGrid and Grid Bag sizers. They are probably the most powerful sizers but also take more effort to use of course. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Cheers, Krissy --- Testing the waters is always fun... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxpython question
Hi, I'm not sure if I could ask questions about wx in this list or not, hopefully it's okay? If not I guess disregard this question. But, does anyone have any idea of if it's possible to make a frame that will latch on to the parent frame (e.g. if you resize the parent, the child also resizes, if you move the parent, the child also moves), aside from using the MDI window that's wxpython provides? -- Cheers, Krissy --- Testing the waters is always fun... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxpython question
Kristina Ambert krissy.amb...@gmail.com wrote I'm not sure if I could ask questions about wx in this list or not, hopefully it's okay? If not I guess disregard this question. Yes its fine but you will get more complete answers in the wx mailing list. But, does anyone have any idea of if it's possible to make a frame that will latch on to the parent frame (e.g. if you resize the parent, the child also resizes, if you move the parent, the child also moves), aside from using the MDI window that's wxpython provides? Yes, I think so - I'm not 100% sure I know what you mean. But the standard wxPython layout managers should control all that for you. Look into the docs for FlexGrid and Grid Bag sizers. They are probably the most powerful sizers but also take more effort to use of course. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython vs PyQt
I just would like to correct my incomplete PyQT pricing list from above and mislead none. If you intent to write commercial programs you have to pay: 400 EURO for PyQT AND3000 EURO for QT !!! - On Tue, Mar 10, 2009 at 2:27 PM, andré palma andre...@gmail.com wrote: Neven Goršić wrote: Thank you all. It was not easy to decide what to learn/use, so I Google some more. I have found that PyQT is more stable, faster, more consistent and more expensive :). 400 EURO is too much for playing around with some GUI, but GPL licence resolves that issue. The cons are C++ oriented documentation, editor and some structures ... Neven --- On Thu, Mar 5, 2009 at 3:10 AM, johnf jfabi...@yolo.com mailto:jfabi...@yolo.com wrote: On Wednesday 04 March 2009 04:56:37 pm Alan Gauld wrote: Kent Johnson ken...@tds.net mailto:ken...@tds.net wrote I've heard good things about Dabo, never tried it myself though. http://dabodev.com/ I looked at Dabo but decided not to try it since it was yet another framework. Although it's based on wxPython they have layered their own widgets on top which is what the GUI Builder uses. (PythonCard fell into the same hole) Yes, it's true that Dabo has wrapped (subclassed) most of the controls. The purpose of course was to provide developer ease of use. If you are building a real business app then I doubt there is anything better in the python world. I personally have used both VB and Delphi and see Dabo on the same level. With one exception - we have a beta GUI builder. Everything that has been done in Dabo is the very same things that all developers would be required to do if they access a database and associate fields to controls. BTW there is nothing stopping a Dabo developer from directly using wx controls. Dabo prevents nothing. So Alan, I don't see my work as falling into any hole. But the web pages and writeup looked good and the forum seemed to be active and not all negative. Alan G Hey, i've found your discussion interesting. I'm developing my final course project and i'm using a toll called Glade to create my application. It has a IDE that let you to create your windows, with text boxes, combo boxes ... everything! And the really good thing: it is totally open source =) It's quit simple to do applications with glade. You just have to create your GUI with it IDE and then you just need to link the signals to de functions that actually preform actions. GLADE: http://glade.gnome.org/ http://www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm (examples how to use glade and pyGTK) and if you look for it in youtube there is a lot of a good video tutorials -- John Fabiani ___ Tutor maillist - Tutor@python.org mailto:Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython vs PyQt
2009/3/16 Neven Goršić neven.gor...@gmail.com: I just would like to correct my incomplete PyQT pricing list from above and mislead none. If you intent to write commercial programs you have to pay: 400 EURO for PyQT AND 3000 EURO for QT !!! actually, QT is moving to LGPL, so in the near future you may be able not to pay anything even for writing some proprietary programs anyway, you're still free to use the GPL version to play around with it and to develop free software apps -- Elena ``of Valhalla'' email: elena.valha...@gmail.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython vs PyQt
2009/3/16 Elena of Valhalla elena.valha...@gmail.com: 2009/3/16 Neven Goršić neven.gor...@gmail.com: I just would like to correct my incomplete PyQT pricing list from above and mislead none. If you intent to write commercial programs you have to pay: 400 EURO for PyQT AND 3000 EURO for QT !!! actually, QT is moving to LGPL, so in the near future you may be able not to pay anything even for writing some proprietary programs Qt is available now under LGPL. PyQt is still GPL / Commercial AFAICT. anyway, you're still free to use the GPL version to play around with it and to develop free software apps Yes, but be careful with the playing around - Both the Qt and PyQt Commercial Licenses prevent you from developing code using the GPL versions and subsequently selling that code under the commercial license. You must purchase a commercial license at the start of your development. http://www.riverbankcomputing.co.uk/software/pyqt/license Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython vs PyQt
Thank you all. It was not easy to decide what to learn/use, so I Google some more. I have found that PyQT is more stable, faster, more consistent and more expensive :). 400 € is too much for playing around with some GUI, but GPL licence resolves that issue. The cons are C++ oriented documentation, editor and some structures ... Neven --- On Thu, Mar 5, 2009 at 3:10 AM, johnf jfabi...@yolo.com wrote: On Wednesday 04 March 2009 04:56:37 pm Alan Gauld wrote: Kent Johnson ken...@tds.net wrote I've heard good things about Dabo, never tried it myself though. http://dabodev.com/ I looked at Dabo but decided not to try it since it was yet another framework. Although it's based on wxPython they have layered their own widgets on top which is what the GUI Builder uses. (PythonCard fell into the same hole) Yes, it's true that Dabo has wrapped (subclassed) most of the controls. The purpose of course was to provide developer ease of use. If you are building a real business app then I doubt there is anything better in the python world. I personally have used both VB and Delphi and see Dabo on the same level. With one exception - we have a beta GUI builder. Everything that has been done in Dabo is the very same things that all developers would be required to do if they access a database and associate fields to controls. BTW there is nothing stopping a Dabo developer from directly using wx controls. Dabo prevents nothing. So Alan, I don't see my work as falling into any hole. But the web pages and writeup looked good and the forum seemed to be active and not all negative. Alan G -- John Fabiani ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython vs PyQt
Neven Gorsic neven.gor...@gmail.com wrote I read also that none of them are even near as good as Delphi or VB. Is it really so? I had a look around various GUII building tools for wxPython but none of them were near Delphi/VB standard. I've never used pyQT or even vanilla Qt so the idea of learning yet another GUI toolkit kept me away from that. FWIW The only Gui builder I got to work even half way decently was the one in SPE. But in practice I still just hand crank them... Its really not that much harder for the small scale stuff I do. If I had a big GUI project I suspect I'd build it in Delphi and call out to Python using COM or somesuch. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython vs PyQt
There is a not-free GUI builder, wxDesigner, that isn't too bad (except for costing money). http://www.roebling.de The GLADE GUI builder for Gtk is very nice, however. http://www.pygtk.org/ For windows: http://gladewin32.sourceforge.net/ Cheers ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython vs PyQt
On Wed, Mar 4, 2009 at 9:06 AM, Neven Goršić neven.gor...@gmail.com wrote: Hi! I am about to begin to learn GUI programming with Python. What are pros and cons for PyQT and wxPython? I read that PyQT has PyQT Designer which makes GUI programming easier. Is it owned and supported by Nokia? What about wxPython? Boa Constructor is not developed any more ... Is there any program like QT Designer? I've heard good things about Dabo, never tried it myself though. http://dabodev.com/ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython vs PyQt
On Wednesday 04 March 2009 04:56:37 pm Alan Gauld wrote: Kent Johnson ken...@tds.net wrote I've heard good things about Dabo, never tried it myself though. http://dabodev.com/ I looked at Dabo but decided not to try it since it was yet another framework. Although it's based on wxPython they have layered their own widgets on top which is what the GUI Builder uses. (PythonCard fell into the same hole) Yes, it's true that Dabo has wrapped (subclassed) most of the controls. The purpose of course was to provide developer ease of use. If you are building a real business app then I doubt there is anything better in the python world. I personally have used both VB and Delphi and see Dabo on the same level. With one exception - we have a beta GUI builder. Everything that has been done in Dabo is the very same things that all developers would be required to do if they access a database and associate fields to controls. BTW there is nothing stopping a Dabo developer from directly using wx controls. Dabo prevents nothing. So Alan, I don't see my work as falling into any hole. But the web pages and writeup looked good and the forum seemed to be active and not all negative. Alan G -- John Fabiani ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython dialog problem
On Thu, Feb 19, 2009 at 11:04 PM, Garry Willgoose garry.willgo...@newcastle.edu.au wrote: I'm just porting an old code from a GUI in Tkinter to one in wxPython and am having a problem with one of the dialog widgets. This is on OSX. The code below gives the result result= 5104 5103 5104 as expected but if I substitute the single line form that is commented out (as per the wxPython book) I get result= 2 5103 5104 can anyone enlighten me as to what is going on? I;m on OSX python 2.5.2 and wxPython 2.8.9.1 Apparently ShowModal() returns one of wxID_OK, wxID_CANCEL, wxID_YES, wxID_NO whereas MessageBox() returns one of wxYES, wxNO, wxCANCEL, wxOK These are not the same: In [1]: import wx In [3]: wx.ID_OK, wx.ID_CANCEL, wx.ID_YES, wx.ID_NO Out[3]: (5100, 5101, 5103, 5104) In [4]: wx.YES, wx.NO, wx.CANCEL, wx.OK Out[4]: (2, 8, 16, 4) Kent code fragment dlg=wx.MessageDialog(None,text,title,wx.YES_NO | wx.ICON_QUESTION) result=dlg.ShowModal() # result=wx.MessageBox(text,title,wx.YES_NO | wx.ICON_QUESTION) print 'result=',result,wx.ID_YES,wx.ID_NO end code fragment ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxPython dialog problem
I'm just porting an old code from a GUI in Tkinter to one in wxPython and am having a problem with one of the dialog widgets. This is on OSX. The code below gives the result result= 5104 5103 5104 as expected but if I substitute the single line form that is commented out (as per the wxPython book) I get result= 2 5103 5104 can anyone enlighten me as to what is going on? I;m on OSX python 2.5.2 and wxPython 2.8.9.1 code fragment dlg=wx.MessageDialog(None,text,title,wx.YES_NO | wx.ICON_QUESTION) result=dlg.ShowModal() # result=wx.MessageBox(text,title,wx.YES_NO | wx.ICON_QUESTION) print 'result=',result,wx.ID_YES,wx.ID_NO end code fragment ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users] passing file name from one script to theGUI class
I do not currently have wx installed, but I can see the errors... I think some information will help you more than answers in this instance. When you 'import clases_calling', what you are doing is creating a new namespace. Inside that namespace is the class 'funct'. In your code, you call the function 'clases_calling.func_call' which does not exist because it is hidden inside of the class 'funct'. To access this function you would have to 'clases_calling.funct.func_call(self)'. This is bad practice, and defeats the purpose of using a class. Which is understandable since the class 'funct' is not necessary here. All you need is a function that will return the new filename right? So, in the clases_calling module place a 'getnewfilename' function which will return the new filename (no class in clases_calling) and in your 'readfile.py' call it by 'clases_calling.getnewfilename()'. Also, when you try to call 'imagetobit' from your current 'func_call' function it will fail because in *this* module (clases_calling.py) you have it imported as 'MainWindow.imagetobit'. I would highly recommend *not* putting this code in this module anyway, intuitively it would belong in the 'OnRead' method right after the call to your new function 'getnewfilename'. More errors to be... sigh. Here we go. In your function 'imagetobit' in readfile.py you should get an error because 'self' is not defined. You have not put self in the argument list as you did in all the other methods of MainWindow. This also means that self.imageFile1 will not be defined either, and should give you an error when trying to define it. If you adjust the imagetobit function so that it is a method of the class, we see that the imagename parameter is no longer necessary, as we can set the self.imageFile variable directly from one of the other functions. Also, I see code that looks very similar in the __init__ method of MainWindow and the function imagetobit. I suggest that you change this so that in the __init__ method you actually call self.imagetobit. To summarize: 1) Change clases_calling.py to be a single function that return the new filename as a string. 2) Change MainWindow.OnRead so that it calls this new function first (I used clases_calling.getnewfilename()), then self.imagetobit(), and finally run the rest of the commented stuff you have there (Remembering that the Image redrawing has already been done in self.imagetobit() you can delete it here) 3) Change imagetobit so that it is a method of the class MainWindow, and remove the imagename parameter 4) Change all references of self.imageFile1 to just self.imageFile. You do not need the extra. 5) Change MainWindow.__init__ so that it calls self.imagetobit() immediately after you set the variable self.imageFile And... I think that's everything. IMHO the important concept inherently missed in these two modules is that the names of the functions and variable inside are hidden behind the names. i.e. import math is used as math.sqrt, instead of just sqrt. HTH, JS ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [wxPython-users] Dynamically loading images on the panel of GUI
hello everyone, i made a small applicatin where i need to display an image on a panel. and then when i press the read button it should read another image and display it on the same panel. Its working but i have to press the read button two times then only its working import wx import os APP_SIZE_X = 700 APP_SIZE_Y = 300 class MainWindow(wx.Frame): def __init__(self): wx.Frame.__init__(self,None,-1,Agent-Based Model of Residential Development, size = (APP_SIZE_X, APP_SIZE_Y)) self.panel = wx.Panel(self,-1) self.imageFile = r10001t0.asc.jpg # provide a diff file name in same directory/path self.bmp = wx.Image(self.imageFile,wx.BITMAP_TYPE_JPEG ).ConvertToBitmap() wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120)) button42 = wx.Button(self.panel, -1, Read, pos=(240,20)) self.Bind(wx.EVT_BUTTON, self.OnRead,button42) def OnRead(self,event): self.imageFile1=DSCN3378.jpg # you have to provide a diff image file name self.bmp = wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG ).ConvertToBitmap() wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120)) app = wx.PySimpleApp() MainWindow().Show() app.MainLoop() Load two different jpeg images. -- Varsha ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users] Dynamically loading images on the panel of GUI
This problem is getting solved if i use the Refresh function in the button handler. But I have a function where i am generating Jpeg images dynamically in a separate script. And i need to load these images on GUI as soon as they start generating. They have common names like xyz1.jpeg and xyz2.jpeg. And i need to start loading images one after another on the gui panel when they are created. these images are created one after another with a particular time delay(not constant). So i have to check when they are created, and i should load them on gui. So how should i communicate to the gui that image has been created and it should load the image ? On Dec 2, 2007 4:29 PM, Varsha Purohit [EMAIL PROTECTED] wrote: hello everyone, i made a small applicatin where i need to display an image on a panel. and then when i press the read button it should read another image and display it on the same panel. Its working but i have to press the read button two times then only its working import wx import os APP_SIZE_X = 700 APP_SIZE_Y = 300 class MainWindow(wx.Frame): def __init__(self): wx.Frame.__init__(self,None,-1,Agent-Based Model of Residential Development, size = (APP_SIZE_X, APP_SIZE_Y)) self.panel = wx.Panel(self,-1) self.imageFile = r10001t0.asc.jpg # provide a diff file name in same directory/path self.bmp = wx.Image(self.imageFile,wx.BITMAP_TYPE_JPEG).ConvertToBitmap() wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120)) button42 = wx.Button(self.panel, -1, Read, pos=(240,20)) self.Bind(wx.EVT_BUTTON, self.OnRead ,button42) def OnRead(self,event): self.imageFile1=DSCN3378.jpg # you have to provide a diff image file name self.bmp = wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG).ConvertToBitmap() self.obj = wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120)) self.obj.Refresh() app = wx.PySimpleApp() MainWindow().Show() app.MainLoop() Load two different jpeg images. -- Varsha -- Varsha Purohit, Graduate Student ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [wxPython-users] passing file name from one script to the GUI class
hello All, I am attaching two scripts. One is readfile.py which is a gui script where there is a image display panel and a button. Now what i want is when i click on the button, then it should call a function which is there in second script clases_calling.py which basically passes the second image file name to the readfile and it should call imagetobit function of the gui script and display the passed imagefile name. I am getting runtime errors thanks -- Varsha Purohit, Graduate Student from readfile import MainWindow import os class funct: def func_call(self): imagename = r10001t0.asc.jpg newImage = imagetobit(imagename) import wx import os import IO import clases_calling APP_SIZE_X = 700 APP_SIZE_Y = 300 developerData = developers.txt class MainWindow(wx.Frame): def __init__(self): wx.Frame.__init__(self,None,-1,Agent-Based Model of Residential Development, size = (APP_SIZE_X, APP_SIZE_Y)) ##panel = wx.Panel(self,-1) ##wx.StaticText(panel,-1,first,(35,20)) ##self.txtBox1 = wx.TextCtrl(panel,-1,pos=(60,20),size=(30,20)) ## ##wx.StaticText(panel,-1,sec,(95,20)) ##self.txtBox2 = wx.TextCtrl(panel,-1,pos=(120,20),size=(30,20)) ## ##wx.StaticText(panel,-1,third,(155,20)) ##self.txtBox3 = wx.TextCtrl(panel,-1,pos=(185,20),size=(30,20)) self.panel = wx.Panel(self,-1) self.imageFile = r10001t0.asc.jpg self.bmp = wx.Image(self.imageFile,wx.BITMAP_TYPE_JPEG).ConvertToBitmap() wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120)) button42 = wx.Button(self.panel, -1, Read, pos=(240,20)) self.Bind(wx.EVT_BUTTON, self.OnRead,button42) def OnRead(self,event): clases_calling.func_call(self) ##self.imageFile1=DSCN3378.jpg ##self.bmp = wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG).ConvertToBitmap() ##self.obj = wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120)) ##self.obj.Refresh() ##batch_data = IO.readDevelopers(developerData) ##for model_run in batch_data: ##for rec in batch_data[model_run]: ##self.txtBox1.write(rec.pop(0)) ##self.txtBox2.write(rec.pop(0)) ##self.txtBox3.write(rec.pop(0)) ##self.Destroy() def imagetobit(imagename): self.imageFile1=imagename self.bmp = wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG).ConvertToBitmap() self.obj = wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120)) self.obj.Refresh() app = wx.PySimpleApp() MainWindow().Show() app.MainLoop() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users]How to avoid the traces of frame or panelwindow
Varsha Purohit [EMAIL PROTECTED] wrote I created a simple frame, but when i move the frame or any panel window i get traces of the windows all over which makes the screen look shabby. How can i avoid getting them ? sample code for a panel is # simple.py import wx app = wx.App() frame = wx.Frame(None, -1, 'simple.py') frame.Show() app.MainLoop() You need to create a subclass of App or use PySimpleApp. The best way is to subclass App: import wx class MyApp(wx.App): def OnInit(self): frame = wx.Frame(None, -1, 'simple') frame.Show() return True app = MyApp() app.MainLoop() Does that work? Also, i have another problem, whenever i execute any wxpython program inorder to execute it again i have to close all the programs including the shell and then restart python otherwise i get like 25lines of some stupid error messages having no link to the program. I have to close all python programs again !!! Does anybody now why i am getting this No, but it could be related to the fact that your code wasn't subclassing App. See if the same happens with the sample above. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [wxPython-users]How to avoid the traces of frame or panel window
Hello Everyone, I created a simple frame, but when i move the frame or any panel window i get traces of the windows all over which makes the screen look shabby. How can i avoid getting them ? sample code for a panel is # simple.py import wx app = wx.App() frame = wx.Frame(None, -1, 'simple.py') frame.Show() app.MainLoop() what should i add in the above code to not get the traces of the window. Also, i have another problem, whenever i execute any wxpython program inorder to execute it again i have to close all the programs including the shell and then restart python otherwise i get like 25lines of some stupid error messages having no link to the program. I have to close all python programs again !!! Does anybody now why i am getting this thanks, -- Varsha Purohit ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users] How to save file name of file openedfromwx.FileDialog ?
Hello Alan, What i want is i just need a file picker to chooose the file and display the file name in the text box. I need to open about 4 files like that. That is the front end work. In the back end i am making a list variable to which i have to send the information about the selected files. And that list is read and files are opened in another script. So, i guess i need to improve the code more to choose the file, display just the file information and may be send whole file path to the list. I need to work more on that i guess.Thanks for reminding me... -Varsha On Nov 18, 2007 1:03 AM, Alan Gauld [EMAIL PROTECTED] wrote: Varsha Purohit [EMAIL PROTECTED] wrote I note that you got it wotking but just to clarify... I am actually calling the binding function and then writing it into the text value... class ScrolledWindow(wx.Frame): def __init__(self, parent, id, title): txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20)) name = self.Bind(wx.EVT_BUTTON, self.OnOpen, button11) txt1.write(name) The Bind function does not execute the handler method it simply registers it within wxPython for future use when the button event is triggered. The return value from Bind is not the return value of the method being bound. The method only gets called when the button is pressed, thats why you have to put the write() call in the event handler itself. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [wxPython-users] How to save file name of file opened from wx.FileDialog ?
Hello Everyone, In my application i need to select a file using open dialog box. And then i dont need to open the file. I just need to display the name of the selected file in a text control. And then open the file in later part of the program. But i am not able to get the file name and display it in the text control. Here is the sample code. import wx import os Fname = '' #Global variable to hold the file name. class ScrolledWindow(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(350, 300)) panel = wx.Panel(self, -1) txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20)) button11 = wx.Button(panel, -1, Open, pos=(200,100)) self.Bind(wx.EVT_BUTTON, self.OnOpen, button11) txt1.write(Fname) self.Centre() self.Show() def OnOpen(self,event): self.dirname = '' dlg = wx.FileDialog(self, Choose a file, self.dirname,, *.*, wx.OPEN) if dlg.ShowModal()==wx.ID_OK: self.filename=dlg.GetFilename() Fname = self.filename self.dirname=dlg.GetDirectory() dlg.Destroy() app = wx.App() ScrolledWindow(None, -1, 'Aliens') app.MainLoop() Any help is appreciated thanks, -- Varsha Purohit, Graduate Student ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users] How to save file name of file opened fromwx.FileDialog ?
Varsha Purohit [EMAIL PROTECTED] wrote later part of the program. But i am not able to get the file name and display it in the text control. Here is the sample code. Fname = '' #Global variable to hold the file name. You don't need this since its stored in self.filename. class ScrolledWindow(wx.Frame): def __init__(self, parent, id, title): txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20)) If you want to write to it you need to store it in the object so this should be self.txt1 txt1.write(Fname) You can't write the filename yet as it hasn't been fetched def OnOpen(self,event): self.dirname = '' dlg = wx.FileDialog(self, Choose a file, self.dirname,, *.*, wx.OPEN) if dlg.ShowModal()==wx.ID_OK: self.filename=dlg.GetFilename() Here you get the filename but don't write it to the text control HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users] How to save file name of file opened fromwx.FileDialog ?
Hi Alan, I am actually calling the binding function and then writing it into the text value... i tried using simple print in the openfile function and it shows the filename. I am trying to return the file name value but even that is not responding... class ScrolledWindow(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(350, 300)) panel = wx.Panel(self, -1) txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20)) button11 = wx.Button(panel, -1, Open, pos=(200,100)) name = self.Bind(wx.EVT_BUTTON, self.OnOpen, button11) txt1.write(name) self.Centre() self.Show() def OnOpen(self,event): self.dirname = '' dlg = wx.FileDialog(self, Choose a file, self.dirname,, *.*, wx.OPEN) if dlg.ShowModal()==wx.ID_OK: self.filename=dlg.GetFilename() Fname = self.filename self.dirname=dlg.GetDirectory() #f=open(os.path.join(self.dirname, self.filename),'r') #self.control.SetValue(f.read()) # self.txt1.WriteText(Fname) f.close() dlg.Destroy() return Fname app = wx.App() ScrolledWindow(None, -1, 'Aliens') app.MainLoop() I donno the alternative to this now... :( On Nov 17, 2007 3:35 PM, Alan Gauld [EMAIL PROTECTED] wrote: Varsha Purohit [EMAIL PROTECTED] wrote later part of the program. But i am not able to get the file name and display it in the text control. Here is the sample code. Fname = '' #Global variable to hold the file name. You don't need this since its stored in self.filename. class ScrolledWindow(wx.Frame): def __init__(self, parent, id, title): txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20)) If you want to write to it you need to store it in the object so this should be self.txt1 txt1.write(Fname) You can't write the filename yet as it hasn't been fetched def OnOpen(self,event): self.dirname = '' dlg = wx.FileDialog(self, Choose a file, self.dirname,, *.*, wx.OPEN) if dlg.ShowModal()==wx.ID_OK: self.filename=dlg.GetFilename() Here you get the filename but don't write it to the text control HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Varsha Purohit ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users] How to save file name of file opened from wx.FileDialog ?
HI Alan, Thanks for suggestion its working now import wx import os class ScrolledWindow(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(350, 300)) panel = wx.Panel(self, -1) self.txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20)) self.button11 = wx.Button(panel, -1, Open, pos=(200,100)) self.button11.Bind(wx.EVT_BUTTON, self.OnOpen) self.Centre() self.Show() def OnOpen(self,event): self.dirname = '' dlg = wx.FileDialog(self, Choose a file, self.dirname,, *.*, wx.OPEN) if dlg.ShowModal()==wx.ID_OK: self.filename=dlg.GetFilename() self.dirname=dlg.GetDirectory() self.txt1.write(self.filename) dlg.Destroy() app = wx.App() ScrolledWindow(None, -1, 'Aliens') app.MainLoop() On Nov 17, 2007 12:44 PM, Varsha Purohit [EMAIL PROTECTED] wrote: Hello Everyone, In my application i need to select a file using open dialog box. And then i dont need to open the file. I just need to display the name of the selected file in a text control. And then open the file in later part of the program. But i am not able to get the file name and display it in the text control. Here is the sample code. import wx import os Fname = '' #Global variable to hold the file name. class ScrolledWindow(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(350, 300)) panel = wx.Panel(self, -1) txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20)) button11 = wx.Button(panel, -1, Open, pos=(200,100)) self.Bind(wx.EVT_BUTTON, self.OnOpen, button11) txt1.write(Fname) self.Centre() self.Show() def OnOpen(self,event): self.dirname = '' dlg = wx.FileDialog(self, Choose a file, self.dirname,, *.*, wx.OPEN) if dlg.ShowModal()==wx.ID_OK: self.filename=dlg.GetFilename() Fname = self.filename self.dirname=dlg.GetDirectory() dlg.Destroy() app = wx.App() ScrolledWindow(None, -1, 'Aliens') app.MainLoop() Any help is appreciated thanks, -- Varsha Purohit, Graduate Student ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [wxPython-users] Displaying filename of open dialog box
Hello, I am new to wxPython. I have made an application where i created a button which opens the file from a directory. I created a static text box near the button. I want to display the filename of file which is opened using this open button. How can i read the file opened and put that text in the static text box??? thanks, -- Varsha Purohit, Graduate Student ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [wxPython-users] Loading default values for text box and choice
Hello, I wanted to know how to load text box with the default value Eg. In these lines there is a static text and a text box created ... and if i want to load value '3' in the text box how can i do that ?? wx.StaticText(panel, -1, Random Seed, (550,200)) wx.TextCtrl(panel,-1,pos=(620,200),size=(50,20)) and also in the Choice box simpleList2 = ['Unbiased Attitude ','Biased Attitude'] wx.Choice(panel, -1, (670,570),choices=simpleList2) if i want to load the first value of simplelist2 in the choice box by default when the application runs... thanks in advance, -- Varsha Purohit, ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] [wxPython-users] Executing a python script in WxPython
Hello, I have an application where i need to run a python script from wxpython gui. I am calling the script from the button click event. And the moment button is pressed the python script should be executed. thanks, Varsha Purohit, Graduate Student ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users] Executing a python script in WxPython
Varsha Purohit wrote: Hello, I have an application where i need to run a python script from wxpython gui. I am calling the script from the button click event. And the moment button is pressed the python script should be executed. If you can import the script and call the required function that is the simplest approach. If you have to run the script as from the command line then use os.system or subprocess.Popen. Kent thanks, Varsha Purohit, Graduate Student ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users] Executing a python script in WxPython
Thanks for the help its working now !!! On Nov 13, 2007 7:34 PM, Kent Johnson [EMAIL PROTECTED] wrote: Varsha Purohit wrote: Hello, I have an application where i need to run a python script from wxpython gui. I am calling the script from the button click event. And the moment button is pressed the python script should be executed. If you can import the script and call the required function that is the simplest approach. If you have to run the script as from the command line then use os.system or subprocess.Popen. Kent thanks, Varsha Purohit, Graduate Student ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Varsha Purohit, Graduate Student ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [wxPython-users] Executing a python script in WxPython
Varsha Purohit [EMAIL PROTECTED] wrote I have an application where i need to run a python script from wxpython gui. I am calling the script from the button click event. And the moment button is pressed the python script should be executed. This comes up from time to time and is usually a bad idea. Is there a reason why you cannot import the script as a module and then call a function (or functions) within the script instead of executing the script? That is a much safer and more flexible process. However, if that is impossible you can use subprocess module to execute any external program including python, so simply call that fom your event handler. If you are having difficulties post some sample code and we can give more specific help. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] WxPython Splashscreen?
Trey Keown [EMAIL PROTECTED] wrote Does anyone know how to make a wxPython splashscreen? Using the wxSplashScreen widget? not found any working examples. The wxPython book offers this: class SketchApp(wx.App): def OnInit(self): image = wx.image('splash.bmp', wx.BITMAP_TYPE_BMP) bmp = image.ConvertToBitmap() wx.SpashScreen(bmp,wx.SPLASH_NO_CENTER|wx.SPLAS_TIMEOUT,1000,None,-1) wx.Yield() frame = SketchFrame(None) etc... The book is invaluable for wxPython users. -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] WxPython Splashscreen?
Hey all, Does anyone know how to make a wxPython splashscreen? It would be great if you could show a (working) example, as I have googled this topic, yet have not found any working examples. Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxpython - Grid
Hi, Tell me about Advance usage of wxGrid any site or tutorial. 1. data entry program making invoice Pradeep ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython GUI builders?
Alan Gauld wrote: What's available and in what state of readiness? I tried Boa Constructor but after half a dozen code tweaks I was still running into compatibility errors with the latest wxPython and gave up. I know that Glade is out there, but what state is it in? And PythonCard offers another approach but I haven't looked at it for about 3 years. Are there any others? And which ones do people actually use? Commercial or Freeware. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Dabo is another but it's under continuing development. Colin W. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxPython GUI builders?
What's available and in what state of readiness? I tried Boa Constructor but after half a dozen code tweaks I was still running into compatibility errors with the latest wxPython and gave up. I know that Glade is out there, but what state is it in? And PythonCard offers another approach but I haven't looked at it for about 3 years. Are there any others? And which ones do people actually use? Commercial or Freeware. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython GUI builders?
wxGlade is a good GUI builder, very much like Glade, however it may o may not integrate with your coding style but you should definitively give it a try. PythonCard is a nice concept I personally do something similar but with XML, parse and build the GUI from it, then tweak the layout manually, with PythonCard this is easier to do since it has a resource editor. Personally I would like an IDE + wxPython GUI editor integrated, that would help a lot, I'm starting to work on that myself. Good luck! On 6/13/07, Alan Gauld [EMAIL PROTECTED] wrote: What's available and in what state of readiness? I tried Boa Constructor but after half a dozen code tweaks I was still running into compatibility errors with the latest wxPython and gave up. I know that Glade is out there, but what state is it in? And PythonCard offers another approach but I haven't looked at it for about 3 years. Are there any others? And which ones do people actually use? Commercial or Freeware. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython GUI builders?
At 01:08 PM 6/13/2007, Alan Gauld wrote: What's available and in what state of readiness? I don't have the details you want, but you might look at SPE. http://pythonide.blogspot.com/ Dick Moores ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] WXPython Listbox Problem
Hey friendly users! I'm trying to make a simple program to calculate the odds when playing poker. The idea is that you select both your cards from listboxes. However, no matter what I try, I just can't select a entry in either of the listboxes! I can click all I want, it just won't select. Here's the code which I use to create the boxes: ID_BOX1 = 120 ID_BOX2 = 130 ... #Boxes, to select cards self.box1 = wx.ListBox(parent=self, id=ID_BOX1, size=(60,163) , name='Card 1', choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'],style=0) self.box2 = wx.ListBox(parent=self, id=ID_BOX2, size=(60,163) , name='Card 2', choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'],style=0) self.box1.Bind(wx.EVT_LISTBOX, self.b1func,id=ID_BOX1) self.box2.Bind(wx.EVT_LISTBOX, self.b2func,id=ID_BOX2) I hope anybody can help me. If you need to see the full code, just send me a reply Thanks in advance to anybody reading/helping! Toon Pieton ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] WXPython Listbox Problem
Try ID's higher then 1 ... low ID's are usually taken by wxWidgets. To be safe simply create them with wx.ID_ANY (from the top of my head) and after that: self.box1.Bind(wx.EVT_LISTBOX, self.b1func,id=self.box1.GetId()) Which is a bit more dynamic anyway and saves you some constants. Furthermore, wxPython specific questions could be better answered in the wxPython-users mailinglist to get more succes ;-) Regards, - Jorgen On 12/6/06, Toon Pieton [EMAIL PROTECTED] wrote: Hey friendly users! I'm trying to make a simple program to calculate the odds when playing poker. The idea is that you select both your cards from listboxes. However, no matter what I try, I just can't select a entry in either of the listboxes! I can click all I want, it just won't select. Here's the code which I use to create the boxes: ID_BOX1 = 120 ID_BOX2 = 130 ... #Boxes, to select cards self.box1 = wx.ListBox(parent=self, id=ID_BOX1, size=(60,163) , name='Card 1', choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'],style=0) self.box2 = wx.ListBox(parent=self, id=ID_BOX2, size=(60,163) , name='Card 2', choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'],style=0) self.box1.Bind(wx.EVT_LISTBOX, self.b1func,id=ID_BOX1) self.box2.Bind(wx.EVT_LISTBOX, self.b2func,id=ID_BOX2) I hope anybody can help me. If you need to see the full code, just send me a reply Thanks in advance to anybody reading/helping! Toon Pieton ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor On 12/6/06, Toon Pieton [EMAIL PROTECTED] wrote: Hey friendly users! I'm trying to make a simple program to calculate the odds when playing poker. The idea is that you select both your cards from listboxes. However, no matter what I try, I just can't select a entry in either of the listboxes! I can click all I want, it just won't select. Here's the code which I use to create the boxes: ID_BOX1 = 120 ID_BOX2 = 130 ... #Boxes, to select cards self.box1 = wx.ListBox(parent=self, id=ID_BOX1, size=(60,163) , name='Card 1', choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'],style=0) self.box2 = wx.ListBox(parent=self, id=ID_BOX2, size=(60,163) , name='Card 2', choices=['Ace','King','Queen','Ten','9','8','7','6','5','4','3','2'],style=0) self.box1.Bind(wx.EVT_LISTBOX, self.b1func,id=ID_BOX1) self.box2.Bind(wx.EVT_LISTBOX, self.b2func,id=ID_BOX2) I hope anybody can help me. If you need to see the full code, just send me a reply Thanks in advance to anybody reading/helping! Toon Pieton ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython book
WxPython in Action (Paperback) by Noel Rappin, Robin Dunn i'll probably be picking up a copy of it myself. i've seen positive comments about the book. more reviews available at Amazon US: http://www.amazon.com/exec/obidos/ASIN/1932394621 there's also a wxWidgets book if you need to know the details. hope this helps! -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Core Python Programming, Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython book
Thanks Wes, After posting it dawned on me that the US site might have more (any!) reviews, and sure enough there is one mega review and several shorter ones, none negative. I think I'll be buying... The wxWidgets book I'll pass on, I have an old one from about 10 years ago (from when I was actively programming in C++) which explains the logic behind the toolkit and the wxWidgets reference web pages do all I need now, its really the Python aspects I want a book on. Thanks again, Alan G. - Original Message - From: wesley chun [EMAIL PROTECTED] To: Alan Gauld [EMAIL PROTECTED] Cc: tutor@python.org Sent: Thursday, October 12, 2006 11:38 PM Subject: Re: [Tutor] wxPython book WxPython in Action (Paperback) by Noel Rappin, Robin Dunn i'll probably be picking up a copy of it myself. i've seen positive comments about the book. more reviews available at Amazon US: http://www.amazon.com/exec/obidos/ASIN/1932394621 there's also a wxWidgets book if you need to know the details. hope this helps! -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Core Python Programming, Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython book
There is a good interview on Python 411 last week with the authors of the book. http://www.awaretek.com/python/index.html You can also find a few other shows about gui toolkits in Python. This is a great resource if you want to learn about Python while you commute. --Dennis - Original Message -Date: Thu, 12 Oct 2006 23:50:11 +0100 From: Alan Gauld [EMAIL PROTECTED] Subject: Re: [Tutor] wxPython book To: wesley chun [EMAIL PROTECTED] Cc: tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; format=flowed; charset=iso-8859-1; reply-type=response Thanks Wes, After posting it dawned on me that the US site might have more (any!) reviews, and sure enough there is one mega review and several shorter ones, none negative. I think I'll be buying... The wxWidgets book I'll pass on, I have an old one from about 10 years ago (from when I was actively programming in C++) which explains the logic behind the toolkit and the wxWidgets reference web pages do all I need now, its really the Python aspects I want a book on. Thanks again, Alan G. - Original Message - From: wesley chun [EMAIL PROTECTED] To: Alan Gauld [EMAIL PROTECTED] Cc: tutor@python.org Sent: Thursday, October 12, 2006 11:38 PM Subject: Re: [Tutor] wxPython book WxPython in Action (Paperback) by Noel Rappin, Robin Dunn i'll probably be picking up a copy of it myself. i've seen positive comments about the book. more reviews available at Amazon US: http://www.amazon.com/exec/obidos/ASIN/1932394621 there's also a wxWidgets book if you need to know the details. hope this helps! -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Core Python Programming, Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxPython
Hello. I have made some programs using wxPython (PythonCard). They all seem to have one common nominator. When the program are doing something unrelated unrelated to the graphics (for example, ftp's, works with a document or a file), the graphics freezes. It does unfreeze afterwards, but since the working with the other files might take a few minutes, the user assumes my program has crashed. How can I avoid that the graphics freeze. Thanks in advance -- This email has been scanned for viruses spam by Decna as - www.decna.no Denne e-posten er sjekket for virus spam av Decna as - www.decna.no ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython
Øyvind wrote: Hello. I have made some programs using wxPython (PythonCard). They all seem to have one common nominator. When the program are doing something unrelated unrelated to the graphics (for example, ftp's, works with a document or a file), the graphics freezes. It does unfreeze afterwards, but since the working with the other files might take a few minutes, the user assumes my program has crashed. How can I avoid that the graphics freeze. The problem is that your long-running task is not yielding any time to the GUI to respond to events or update the screen. See this page for a detailed discussion of your options: http://wiki.wxpython.org/index.cgi/LongRunningTasks Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython
How can I avoid that the graphics freeze. here is another example for doing this: http://uucode.com/texts/pylongopgui/pyguiapp.html It uses Tkinter, but it should work in wxPython, too. Kind regards, Karsten. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython shaped window
To totally not answer your question, check out - pythoncard.sourceforge.net It's the Visual Basic Userform IDE of wxPython. :) On 7/1/05, Adam Bark [EMAIL PROTECTED] wrote: On 6/26/05, Adam Cripps [EMAIL PROTECTED] wrote: On 6/25/05, Adam Bark [EMAIL PROTECTED] wrote: Thanks for the info Adam I just seem to be having a problem with the panel size it greys out nearly all the image. Ideally I would like to make the panel transparent but I can't work out how to do that. On 6/25/05, Adam Cripps [EMAIL PROTECTED] wrote: On 6/25/05, Adam Bark [EMAIL PROTECTED] wrote: Is it possible to put controls into a shaped window in wxPython. I have tried putting a button on the demo and it becomes the exact size and shape of the window. Also when I tried to bind it to an action it wouldn't even start.Adam I'm working through something similar myself at the moment. Try adding a wx.Panel to the frame and then the button to the panel. You can position them through pos parameter, but it should default to the top left of the panel and have a good size if you use button.SetSize(button.GetBestSize()) HTH AdamAdam - how much code do you have? Why not post it either here or thewxpython-users list (to which I'm also subscribed) and we can take a look.Adam--http://www.monkeez.orgPGP key: 0x7111B833 I tried posting to the wxpython-users list but I'm not sure it worked nobody replied anyway. Here's my test script: import wx class Frame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, Shaped Window, style = wx.FRAME_SHAPED | wx.SIMPLE_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP ) self.hasShape = False self.delta = (0,0) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.bkground = wx.Bitmap(/home/adam/bkgrnd.gif, wx.BITMAP_TYPE_GIF) w, h = self.bkground.GetWidth(), self.bkground.GetHeight() self.SetClientSize((w, h)) self.Bind(wx.EVT_WINDOW_CREATE, self.SetWindowShape) panel = Panel(self, w, h) panel.Show() dc = wx.ClientDC(self) dc.DrawBitmap(self.bkground, 0,0, True) def SetWindowShape(self, evt): # Use the bitmap's mask to determine the region r = wx.RegionFromBitmap(self.bkground) self.hasShape = self.SetShape(r) def OnPaint(self, event): dc = wx.PaintDC(self) dc.DrawBitmap(self.bkground, 0,0, True) def OnMouseMove(self, evt): if evt.Dragging() and evt.LeftIsDown(): x, y = self.ClientToScreen(evt.GetPosition()) fp = (x - self.delta[0], y - self.delta[1]) self.Move(fp) class Panel(wx.Panel): def __init__(self, parent, width, height): wx.Panel.__init__(self, parent, -1, size=(width, height)) button = wx.Button(self, -1, hello) button.SetSize(button.GetBestSize()) self.SetSize((width, height)) #print dir(self) if __name__ == __main__: app = wx.PySimpleApp() frame = Frame() frame.Show() app.MainLoop() Thanks. Adam. ___Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor-- 'There is only one basic human right, and that is to do as you damn well please.And with it comes the only basic human duty, to take the consequences.' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxPython shaped window
On 6/26/05, Adam Cripps [EMAIL PROTECTED] wrote: On 6/25/05, Adam Bark [EMAIL PROTECTED] wrote: Thanks for the info Adam I just seem to be having a problem with the panel size it greys out nearly all the image. Ideally I would like to make the panel transparent but I can't work out how to do that. On 6/25/05, Adam Cripps [EMAIL PROTECTED] wrote: On 6/25/05, Adam Bark [EMAIL PROTECTED] wrote: Is it possible to put controls into a shaped window in wxPython. I have tried putting a button on the demo and it becomes the exact size and shape of the window. Also when I tried to bind it to an action it wouldn't even start.Adam I'm working through something similar myself at the moment. Try adding a wx.Panel to the frame and then the button to the panel. You can position them through pos parameter, but it should default to the top left of the panel and have a good size if you use button.SetSize(button.GetBestSize()) HTH AdamAdam - how much code do you have? Why not post it either here or thewxpython-users list (to which I'm also subscribed) and we can take a look.Adam--http://www.monkeez.orgPGP key: 0x7111B833 I tried posting to the wxpython-users list but I'm not sure it worked nobody replied anyway. Here's my test script: import wx class Frame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, Shaped Window, style = wx.FRAME_SHAPED | wx.SIMPLE_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP ) self.hasShape = False self.delta = (0,0) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.bkground = wx.Bitmap(/home/adam/bkgrnd.gif, wx.BITMAP_TYPE_GIF) w, h = self.bkground.GetWidth(), self.bkground.GetHeight() self.SetClientSize((w, h)) self.Bind(wx.EVT_WINDOW_CREATE, self.SetWindowShape) panel = Panel(self, w, h) panel.Show() dc = wx.ClientDC(self) dc.DrawBitmap(self.bkground, 0,0, True) def SetWindowShape(self, evt): # Use the bitmap's mask to determine the region r = wx.RegionFromBitmap(self.bkground) self.hasShape = self.SetShape(r) def OnPaint(self, event): dc = wx.PaintDC(self) dc.DrawBitmap(self.bkground, 0,0, True) def OnMouseMove(self, evt): if evt.Dragging() and evt.LeftIsDown(): x, y = self.ClientToScreen(evt.GetPosition()) fp = (x - self.delta[0], y - self.delta[1]) self.Move(fp) class Panel(wx.Panel): def __init__(self, parent, width, height): wx.Panel.__init__(self, parent, -1, size=(width, height)) button = wx.Button(self, -1, hello) button.SetSize(button.GetBestSize()) self.SetSize((width, height)) #print dir(self) if __name__ == __main__: app = wx.PySimpleApp() frame = Frame() frame.Show() app.MainLoop() Thanks. Adam. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython shaped window
On 6/25/05, Adam Bark [EMAIL PROTECTED] wrote: Is it possible to put controls into a shaped window in wxPython. I have tried putting a button on the demo and it becomes the exact size and shape of the window. Also when I tried to bind it to an action it wouldn't even start. Adam I'm working through something similar myself at the moment. Try adding a wx.Panel to the frame and then the button to the panel. You can position them through pos parameter, but it should default to the top left of the panel and have a good size if you use button.SetSize(button.GetBestSize()) HTH Adam -- http://www.monkeez.org PGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython shaped window
Thanks for the info Adam I just seem to be having a problem with the panel size it greys out nearly all the image. Ideally I would like to make the panel transparent but I can't work out how to do that.On 6/25/05, Adam Cripps [EMAIL PROTECTED] wrote: On 6/25/05, Adam Bark [EMAIL PROTECTED] wrote: Is it possible to put controls into a shaped window in wxPython. I have tried putting a button on the demo and it becomes the exact size and shape of the window. Also when I tried to bind it to an action it wouldn't even start.AdamI'm working through something similar myself at the moment.Try adding a wx.Panel to the frame and then the button to the panel.You can position them through pos parameter, but it should default to the top left of the panel and have a good size if you usebutton.SetSize(button.GetBestSize())HTHAdam--http://www.monkeez.orgPGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython shaped window
On Sat, 25 Jun 2005, Adam Bark wrote: Is it possible to put controls into a shaped window in wxPython. I have tried putting a button on the demo and it becomes the exact size and shape of the window. Also when I tried to bind it to an action it wouldn't even start. Hi Adam, You might want to ask this on the wxPython-users mailing list: http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi/11 They're more focused on wxPython GUI stuff than the folks on Tutor, and they appear pretty active too. Best of wishes! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxpython button icons?
Hello, does anyone know if there is a list of widows icons available? I'm creating an application for windows and I'd like to use standard icons for things like a "print" button or "save" button etc. thanks. Jeff ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxpython button icons?
Hey Jeff, -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Peery Hello, does anyone know if there is a list of widows icons available? I'm creating an application for windows and I'd like to use standard icons for things like a print button or save button etc. thanks. Checkout images.py in the wxPython demo directory. If you put it in your python path somewhere you can do an import images and then write code like this (grabbed from the wxPython toolbar demo): pythoncode tb = self.CreateToolBar( wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT ) tb.AddSimpleTool(10, images.getNewBitmap(), New, Long help for 'New') self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10) self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10) tb.AddSimpleTool(20, images.getOpenBitmap(), Open, Long help for 'Open') self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20) self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20) /pythoncode There are probably other ways to do this as well, but there's my .02! Christian http://www.dowski.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] wxpython error when upgrading?
hello, I recently upgraded my wxpython to 2.5, now I get an error message when I try to edit a dialog in the boa constructor that says : collection body not in init, body, fin form - anyone have an idea what this means? thanks. Jeff___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython / Tkinter Grid
On Fri, 1 Apr 2005 09:11:20 +0100 Alan Gauld [EMAIL PROTECTED] wrote: I know a wxPython grid is totally different to a Tkinter grid, but is there a Tkinter equivalent of a wxPython grid? I'm finding wxPython to be fiddly and restrictive... Then Tkinter will be more so. Tk is a fairly basic toolkit, fine for wrapping a command line app in a glossy front end but not for sophisticated GUI work. There is no grid component in Tk out of the box, but some add on toolkits supply one. Try searching on the Vaults of Parnassus or on the ActiveState site if you are determined to try Tkinter... Alan G. Or look here: http://tkinter.unpythonic.net/wiki/Widgets There is a number of links to table widget implementations in Tkinter o nthe wiki page. I hope this helps Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] wxPython / Tkinter Grid
Thanks for the feedback. I should clarify - I find wxPython restrictive fiddly in terms of trying to use a fully featured set of widgets, which are written in C++, trying to use them through a not overly documented Python wrapper. I love Pythoncard more and more. Regards, Liam Clarke On Apr 1, 2005 10:35 PM, Michael Lange [EMAIL PROTECTED] wrote: On Fri, 1 Apr 2005 09:11:20 +0100 Alan Gauld [EMAIL PROTECTED] wrote: I know a wxPython grid is totally different to a Tkinter grid, but is there a Tkinter equivalent of a wxPython grid? I'm finding wxPython to be fiddly and restrictive... Then Tkinter will be more so. Tk is a fairly basic toolkit, fine for wrapping a command line app in a glossy front end but not for sophisticated GUI work. There is no grid component in Tk out of the box, but some add on toolkits supply one. Try searching on the Vaults of Parnassus or on the ActiveState site if you are determined to try Tkinter... Alan G. Or look here: http://tkinter.unpythonic.net/wiki/Widgets There is a number of links to table widget implementations in Tkinter o nthe wiki page. I hope this helps Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor