I recently tried a hand at wxGlade and was happy to see it designs a
GUI for you in minutes. I am a newbie Python coder. I am not completely
aware of GUI programming.
I can easily make menubars etc but I am not too sure sure how to get
more windows poppping to get more information. I mean when you click
something, a new windows would open and ask for input like that. Since
I am using wxGlade and wxPython....can you suggest me a quick tutorial
for GUI programming.
Every help is appreciate,
Thanks 7 8972 di********@gmai l.com wrote: I recently tried a hand at wxGlade and was happy to see it designs a GUI for you in minutes. I am a newbie Python coder. I am not completely aware of GUI programming.
I can easily make menubars etc but I am not too sure sure how to get more windows poppping to get more information. I mean when you click something, a new windows would open and ask for input like that. Since I am using wxGlade and wxPython....can you suggest me a quick tutorial for GUI programming.
Every help is appreciate,
Without having time to go into a full, the way to proceed with Glade
(unless I am mistaken) is to design each window independently of the
others, and to use a button press in one window to create an instance of
another type of window.
Good luck!
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Love me, love my blog http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
I am pasting my code. I created a small little GUI without any
functionality as of yet. I wanted to ask few questions on that. -
#!/usr/bin/env python
-
# -*- coding: UTF-8 -*-
-
# generated by wxGlade 0.4cvs on Thu Jun 15 10:51:12 2006
-
-
import wx
-
-
class MyFrame(wx.Frame):
-
def __init__(self, *args, **kwds):
-
# begin wxGlade: MyFrame.__init__
-
kwds["style"] = wx.DEFAULT_FRAME_STYLE
-
wx.Frame.__init__(self, *args, **kwds)
-
self.panel_1 = wx.Panel(self, -1)
-
-
# Menu Bar
-
self.frame_1_menubar = wx.MenuBar()
-
self.SetMenuBar(self.frame_1_menubar)
-
self.File = wx.Menu()
-
self.CreateNewConfigFile = wx.MenuItem(self.File, wx.NewId(),
-
_("Create New Config File"), "", wx.ITEM_NORMAL)
-
self.File.AppendItem(self.CreateNewConfigFile)
-
self.OpenConfigFile = wx.MenuItem(self.File, wx.NewId(),
-
_("Open Config File"), "", wx.ITEM_NORMAL)
-
self.File.AppendItem(self.OpenConfigFile)
-
self.EditConfigFile = wx.MenuItem(self.File, wx.NewId(),
-
_("Edit Config File"), "", wx.ITEM_NORMAL)
-
self.File.AppendItem(self.EditConfigFile)
-
self.Close = wx.MenuItem(self.File, wx.NewId(), _("Close"), "",
-
wx.ITEM_NORMAL)
-
self.File.AppendItem(self.Close)
-
self.Exit = wx.MenuItem(self.File, wx.NewId(), _("Exit"), "",
-
wx.ITEM_NORMAL)
-
self.File.AppendItem(self.Exit)
-
self.frame_1_menubar.Append(self.File, _("File"))
-
self.Action = wx.Menu()
-
self.AddComputer = wx.MenuItem(self.Action, wx.NewId(), _("Add
-
Computer"), "", wx.ITEM_NORMAL)
-
self.Action.AppendItem(self.AddComputer)
-
self.Shutdown = wx.MenuItem(self.Action, wx.NewId(),
-
_("Shutdown..."), "", wx.ITEM_NORMAL)
-
self.Action.AppendItem(self.Shutdown)
-
self.ShutdownAll = wx.MenuItem(self.Action, wx.NewId(),
-
_("Shutdown All"), "", wx.ITEM_NORMAL)
-
self.Action.AppendItem(self.ShutdownAll)
-
self.frame_1_menubar.Append(self.Action, _("Action"))
-
self.Help = wx.Menu()
-
self.Tutorial = wx.MenuItem(self.Help, wx.NewId(),
-
_("Tutorial"), "", wx.ITEM_NORMAL)
-
self.Help.AppendItem(self.Tutorial)
-
self.AboutUs = wx.MenuItem(self.Help, wx.NewId(), _("About
-
us"), "", wx.ITEM_NORMAL)
-
self.Help.AppendItem(self.AboutUs)
-
self.frame_1_menubar.Append(self.Help, _("Help"))
-
# Menu Bar end
-
self.frame_1_statusbar = self.CreateStatusBar(1, 0)
-
-
self.__set_properties()
-
self.__do_layout()
-
# end wxGlade
-
-
def __set_properties(self):
-
# begin wxGlade: MyFrame.__set_properties
-
self.SetTitle(_("Test"))
-
self.SetSize((600, 450))
-
self.frame_1_statusbar.SetStatusWidths([-1])
-
# statusbar fields
-
frame_1_statusbar_fields = [_("Test Application")]
-
for i in range(len(frame_1_statusbar_fields)):
-
-
self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
-
# end wxGlade
-
-
def __do_layout(self):
-
# begin wxGlade: MyFrame.__do_layout
-
sizer_1 = wx.BoxSizer(wx.VERTICAL)
-
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
-
self.SetAutoLayout(True)
-
self.SetSizer(sizer_1)
-
self.Layout()
-
# end wxGlade
-
-
# end of class MyFrame
-
-
-
class MyApp(wx.App):
-
def OnInit(self):
-
wx.InitAllImageHandlers()
-
frame_1 = MyFrame(None, -1, "")
-
self.SetTopWindow(frame_1)
-
frame_1.Show()
-
return 1
-
-
# end of class MyApp
-
-
if __name__ == "__main__":
-
import gettext
-
gettext.install("app") # replace with the appropriate catalog name
-
-
app = MyApp(0)
-
app.MainLoop()
-
If I click on any of the items of the File Menu, say I click on "Open
config File", I want a new windows to come up.
My questions is when I create a new Frame/Windows in wxGlade, will it
be wxFrame or wxMDI Frame......whic h one should I choose and why ?
I am not completely aware of all the small tools that wxGlade gives and
how to place them.
Any kind of help is greatly appreciated.
Thanks Without having time to go into a full, the way to proceed with Glade (unless I am mistaken) is to design each window independently of the others, and to use a button press in one window to create an instance of another type of window. di********@gmai l.com wrote: I am pasting my code. I created a small little GUI without any functionality as of yet. I wanted to ask few questions on that.
[lots of code ...] If I click on any of the items of the File Menu, say I click on "Open config File", I want a new windows to come up.
My questions is when I create a new Frame/Windows in wxGlade, will it be wxFrame or wxMDI Frame......whic h one should I choose and why ?
I am not completely aware of all the small tools that wxGlade gives and how to place them.
Any kind of help is greatly appreciated.
As I already said I'm a bit to busy to help with specifics right now.
Two places you might go for help:
1: http://www.holdenweb.com/PyConTX2006/wxPythonIntro.pdf
The introductory tutorial I gave at PyCon TX 2006
2: Email to wx************* ****@lists.wxwi dgets.org
There's a fairly friendly community who will take your code as
evidence you are trying to help yourself and explain the basics
as necessary.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Love me, love my blog http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
I am a newbie. I was looking for some code where I could a list of
different items from a file and display it in a list box. Then give a
user the capability to select some.
Basically, reading and writing to a file and displaying them in
different widgets...thats something I am looking for. If anybody can
point me to some good example tutorials...I will be greatly helped.
Thanks,
Every help is appreciated di********@gmai l.com wrote: I am a newbie. I was looking for some code where I could a list of different items from a file and display it in a list box. Then give a user the capability to select some.
Basically, reading and writing to a file and displaying them in different widgets...thats something I am looking for. If anybody can point me to some good example tutorials...I will be greatly helped.
Thanks,
Every help is appreciated
Have you tried looking at the code in the wxPython demo? In the ListBox
control demo, it populates a ListBox with items from a list, but you
could easily translate that into reading from a file, I think. Here's
the full code in case you don't have the demo: import wx
#---------------------------------------------------------------------------
# This listbox subclass lets you type the starting letters of what you want to # select, and scrolls the list to the match if it is found. class FindPrefixListB ox(wx.ListBox): def __init__(self, parent, id, pos=wx.DefaultP osition, size=wx.Default Size, choices=[], style=0, validator=wx.De faultValidator) : wx.ListBox.__in it__(self, parent, id, pos, size, choices, style, validator) self.typedText = '' self.log = parent.log self.Bind(wx.EV T_KEY_DOWN, self.OnKey)
def FindPrefix(self , prefix): self.log.WriteT ext('Looking for prefix: %s\n' % prefix)
if prefix: prefix = prefix.lower() length = len(prefix)
# Changed in 2.5 because ListBox.Number( ) is no longer supported. # ListBox.GetCoun t() is now the appropriate way to go. for x in range(self.GetC ount()): text = self.GetString( x) text = text.lower()
if text[:length] == prefix: self.log.WriteT ext('Prefix %s is found.\n' % prefix) return x
self.log.WriteT ext('Prefix %s is not found.\n' % prefix) return -1
def OnKey(self, evt): key = evt.GetKeyCode( )
if key >= 32 and key <= 127: self.typedText = self.typedText + chr(key) item = self.FindPrefix (self.typedText )
if item != -1: self.SetSelecti on(item)
elif key == wx.WXK_BACK: # backspace removes one character and backs up self.typedText = self.typedText[:-1]
if not self.typedText: self.SetSelecti on(0) else: item = self.FindPrefix (self.typedText )
if item != -1: self.SetSelecti on(item) else: self.typedText = '' evt.Skip()
def OnKeyDown(self, evt): pass
#---------------------------------------------------------------------------
class TestListBox(wx. Panel): def __init__(self, parent, log): self.log = log wx.Panel.__init __(self, parent, -1)
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen']
wx.StaticText(s elf, -1, "This example uses the wx.ListBox control.", (45, 10)) wx.StaticText(s elf, -1, "Select one:", (15, 50)) self.lb1 = wx.ListBox(self , 60, (100, 50), (90, 120), sampleList, wx.LB_SINGLE) self.Bind(wx.EV T_LISTBOX, self.EvtListBox , self.lb1) self.Bind(wx.EV T_LISTBOX_DCLIC K, self.EvtListBox DClick, self.lb1) self.lb1.Bind(w x.EVT_RIGHT_UP, self.EvtRightBu tton) self.lb1.SetSel ection(3) self.lb1.Append ("with data", "This one has data"); self.lb1.SetCli entData(2, "This one has data");
wx.StaticText(s elf, -1, "Select many:", (220, 50)) self.lb2 = wx.ListBox(self , 70, (320, 50), (90, 120), sampleList, wx.LB_EXTENDED) self.Bind(wx.EV T_LISTBOX, self.EvtMultiLi stBox, self.lb2) self.lb2.Bind(w x.EVT_RIGHT_UP, self.EvtRightBu tton) self.lb2.SetSel ection(0)
sampleList = sampleList + ['test a', 'test aa', 'test aab', 'test ab', 'test abc', 'test abcc', 'test abcd' ] sampleList.sort () wx.StaticText(s elf, -1, "Find Prefix:", (15, 250)) fp = FindPrefixListB ox(self, -1, (100, 250), (90, 120), sampleList, wx.LB_SINGLE) fp.SetSelection (0)
def EvtListBox(self , event): self.log.WriteT ext('EvtListBox : %s, %s, %s, %s\n' % (event.GetStrin g(), event.IsSelecti on(), event.GetSelect ion(), event.GetClient Data()))
lb = event.GetEventO bject() data = lb.GetClientDat a(lb.GetSelecti on())
if data is not None: self.log.WriteT ext('\tdata: %s\n' % data)
def EvtListBoxDClic k(self, event): self.log.WriteT ext('EvtListBox DClick: %s\n' % self.lb1.GetSel ection()) self.lb1.Delete (self.lb1.GetSe lection())
def EvtMultiListBox (self, event): self.log.WriteT ext('EvtMultiLi stBox: %s\n' % str(self.lb2.Ge tSelections()))
def EvtRightButton( self, event): self.log.WriteT ext('EvtRightBu tton: %s\n' % event.GetPositi on())
if event.GetEventO bject().GetId() == 70: selections = list(self.lb2.G etSelections()) selections.reve rse()
for index in selections: self.lb2.Delete (index)
#---------------------------------------------------------------------------
def runTest(frame, nb, log): win = TestListBox(nb, log) return win
#---------------------------------------------------------------------------
overview = """<html><b ody> A listbox is used to select one or more of a list of strings. The strings are displayed in a scrolling box, with the selected string(s) marked in reverse video. A listbox can be single selection (if an item is selected, the previous selection is removed) or multiple selection (clicking an item toggles the item on or off independently of other selections). </body></html> """
if __name__ == '__main__': import sys,os import run run.main(['', os.path.basenam e(sys.argv[0])] + sys.argv[1:])
Ther is a short online tutorial on using wxGlade here <a
href="http://www.serpia.org/wxgladeJohn">wx Glade Tutorial</a>
Did you paste any code ?
Also the link for the next message is not working .....
John Salerno wrote: di********@gmai l.com wrote: I am a newbie. I was looking for some code where I could a list of different items from a file and display it in a list box. Then give a user the capability to select some.
Basically, reading and writing to a file and displaying them in different widgets...thats something I am looking for. If anybody can point me to some good example tutorials...I will be greatly helped.
Thanks,
Every help is appreciated
Have you tried looking at the code in the wxPython demo? In the ListBox control demo, it populates a ListBox with items from a list, but you could easily translate that into reading from a file, I think. Here's the full code in case you don't have the demo:
import wx
#---------------------------------------------------------------------------
# This listbox subclass lets you type the starting letters of what you want to # select, and scrolls the list to the match if it is found. class FindPrefixListB ox(wx.ListBox): def __init__(self, parent, id, pos=wx.DefaultP osition, size=wx.Default Size, choices=[], style=0, validator=wx.De faultValidator) : wx.ListBox.__in it__(self, parent, id, pos, size, choices, style, validator) self.typedText = '' self.log = parent.log self.Bind(wx.EV T_KEY_DOWN, self.OnKey)
def FindPrefix(self , prefix): self.log.WriteT ext('Looking for prefix: %s\n' % prefix)
if prefix: prefix = prefix.lower() length = len(prefix)
# Changed in 2.5 because ListBox.Number( ) is no longer supported. # ListBox.GetCoun t() is now the appropriate way to go. for x in range(self.GetC ount()): text = self.GetString( x) text = text.lower()
if text[:length] == prefix: self.log.WriteT ext('Prefix %s is found.\n' % prefix) return x
self.log.WriteT ext('Prefix %s is not found.\n' % prefix) return -1
def OnKey(self, evt): key = evt.GetKeyCode( )
if key >= 32 and key <= 127: self.typedText = self.typedText + chr(key) item = self.FindPrefix (self.typedText )
if item != -1: self.SetSelecti on(item)
elif key == wx.WXK_BACK: # backspace removes one character and backs up self.typedText = self.typedText[:-1]
if not self.typedText: self.SetSelecti on(0) else: item = self.FindPrefix (self.typedText )
if item != -1: self.SetSelecti on(item) else: self.typedText = '' evt.Skip()
def OnKeyDown(self, evt): pass
#---------------------------------------------------------------------------
class TestListBox(wx. Panel): def __init__(self, parent, log): self.log = log wx.Panel.__init __(self, parent, -1)
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen']
wx.StaticText(s elf, -1, "This example uses the wx.ListBox control.", (45, 10)) wx.StaticText(s elf, -1, "Select one:", (15, 50)) self.lb1 = wx.ListBox(self , 60, (100, 50), (90, 120), sampleList, wx.LB_SINGLE) self.Bind(wx.EV T_LISTBOX, self.EvtListBox , self.lb1) self.Bind(wx.EV T_LISTBOX_DCLIC K, self.EvtListBox DClick, self.lb1) self.lb1.Bind(w x.EVT_RIGHT_UP, self.EvtRightBu tton) self.lb1.SetSel ection(3) self.lb1.Append ("with data", "This one has data"); self.lb1.SetCli entData(2, "This one has data");
wx.StaticText(s elf, -1, "Select many:", (220, 50)) self.lb2 = wx.ListBox(self , 70, (320, 50), (90, 120), sampleList, wx.LB_EXTENDED) self.Bind(wx.EV T_LISTBOX, self.EvtMultiLi stBox, self.lb2) self.lb2.Bind(w x.EVT_RIGHT_UP, self.EvtRightBu tton) self.lb2.SetSel ection(0)
sampleList = sampleList + ['test a', 'test aa', 'test aab', 'test ab', 'test abc', 'test abcc', 'test abcd' ] sampleList.sort () wx.StaticText(s elf, -1, "Find Prefix:", (15, 250)) fp = FindPrefixListB ox(self, -1, (100, 250), (90, 120), sampleList, wx.LB_SINGLE) fp.SetSelection (0)
def EvtListBox(self , event): self.log.WriteT ext('EvtListBox : %s, %s, %s, %s\n' % (event.GetStrin g(), event.IsSelecti on(), event.GetSelect ion(), event.GetClient Data()))
lb = event.GetEventO bject() data = lb.GetClientDat a(lb.GetSelecti on())
if data is not None: self.log.WriteT ext('\tdata: %s\n' % data)
def EvtListBoxDClic k(self, event): self.log.WriteT ext('EvtListBox DClick: %s\n' % self.lb1.GetSel ection()) self.lb1.Delete (self.lb1.GetSe lection())
def EvtMultiListBox (self, event): self.log.WriteT ext('EvtMultiLi stBox: %s\n' % str(self.lb2.Ge tSelections()))
def EvtRightButton( self, event): self.log.WriteT ext('EvtRightBu tton: %s\n' % event.GetPositi on())
if event.GetEventO bject().GetId() == 70: selections = list(self.lb2.G etSelections()) selections.reve rse()
for index in selections: self.lb2.Delete (index)
#---------------------------------------------------------------------------
def runTest(frame, nb, log): win = TestListBox(nb, log) return win
#---------------------------------------------------------------------------
overview = """<html><b ody> A listbox is used to select one or more of a list of strings. The strings are displayed in a scrolling box, with the selected string(s) marked in reverse video. A listbox can be single selection (if an item is selected, the previous selection is removed) or multiple selection (clicking an item toggles the item on or off independently of other selections). </body></html> """
if __name__ == '__main__': import sys,os import run run.main(['', os.path.basenam e(sys.argv[0])] + sys.argv[1:])
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Edilmar |
last post by:
Hi,
First of all, I'm new in Python...
I have worked with manu langs and IDEs, like Delphi, VB, JBuilder, Eclipse,
Borland C++, Perl, etc...
Then, today I think IDEs like Delphi have a excelent environment to develop
apps with little time. I saw many people talking about Python like a easy
lang to learn and to develop. But I have look at IDEs for Python, or ways
|
by: Anand K Rayudu |
last post by:
Hi All,
I am new to python & want to build some GUI dialogs.
Can some one please suggest some document reference.
I am hoping that standard python install will have some GUI development
modules & GUI builder in built.
I have python 2.3.3.
Can some one please suggest
|
by: Al Dykes |
last post by:
I'm looking for info on programming with glade on python, and maybe
some sample code to hack. I've got python installed, but need a howto
for glade and google doesn't help me.
Any suggestions ?
|
by: BOOGIEMAN |
last post by:
Well that's it, how do I make Windows Application with Python ???
Is there simple way that works 100% ? How can I rework visual design
done in VS 2003 to use it for my python program ?
|
by: Madhusudan Singh |
last post by:
Is there such a thing for python ? Like Qt Designer for instance ?
| |
by: alfaeco |
last post by:
Hello
I am looking for a good IDE for Python. Commercial or Open Software.
If possible with visual GUI designer.
For the moment I am considering Komodo.
Any suggestions?
|
by: jiang.haiyun |
last post by:
Now i began to learn GUI programming. There are so many
choices of GUI in the python world, wxPython, pyGTK, PyQT,
Tkinter, .etc, it's difficult for a novice to decide, however.
Can you draw a comparison among them on easy coding, pythonish design,
beautiful and generous looking, powerful development toolkit, and
sufficient documentation, .etc.
It's helpful for a GUI beginner.
Thank you.
|
by: kromakey |
last post by:
Hi,
Are there any free visual GUI IDE's available for python/jython, which
have a drag and drop form designer similar to Visual Studio or
Delphi ?
Cheers
kromakey
|
by: dominiquevalentine |
last post by:
anyone have any advice as to where to start if i say..wanted to
program the ipods UI? I have one python project under my belt so far,
and i'm going for my second. I want to try to mimic the ipod using
python -- that is, basically, i want a virtual ipod in a window, using
either pygtk or wxglade if possible (learning both).
not sure if html works..
<img src="http://media.arstechnica.com/journals/apple.media/thumb/...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |