I am experiencing a strange cross-platform issue with my python
program.
I am using wxRadioBox to create radio buttons. When I run the python
code on a mac, everything works perfectly, but not on a pc. On the pc,
no matter what selection I made, the form would think that I was
choosing the 1st (top) option.
I am astounded that everything else could work and something this
simple could have cross-platform issues.
I looked into wxRadioBox online and no one seems to have any similar
errors. I was thinking it might be the installation of the wx module on
the pc, but I somehow doubt it.
Does anyone have any insight as to what is going on here?
# BEGIN CODE
import wx;
SUBMIT_BUTTON = wx.ID_HIGHEST + 10;
class regFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title,
pos=(100, 100), size=(800, 600));
fileDialog = wx.FileDialog(self, "Select a file to which to write",
style = wx.SAVE | wx.OVERWRITE_PROMPT,
wildcard="*.txt|Text");
if(fileDialog.ShowModal() != wx.ID_OK):
print "No file specified - closing";
self.Close();
return;
write_file = fileDialog.GetPath();
self.write_file = open(write_file, "a");
# init main frame with menu and status bars
menuBar = wx.MenuBar();
fileMenu = wx.Menu();
fileMenu.Append(wx.ID_ABOUT, "&About\tAlt-A", "About this program");
fileMenu.AppendSeparator();
fileMenu.Append(wx.ID_EXIT, "&Quit\tAlt-Q", "Quit this program");
menuBar.Append(fileMenu, "&File");
self.SetMenuBar(menuBar);
self.CreateStatusBar();
self.ctrl_sizer = wx.GridBagSizer(5, 15);
# build the controls
# TO MODIFY THE LIST OF SIZES, CHANGE THIS:
self.valid_sizes = ['4XLT', '3XLT', '2XLT', '2XL', 'XLT', 'LT', 'XL',
'L', 'M', 'S', 'XS', 'XXS'];
instructions = "Enter your netid, full name, and size in the " + \
"boxes below and press the 'Submit Order' button to place " + \
"your order.";
self.instruction_text = wx.StaticText(self, -1, instructions);
self.id_text = wx.StaticText(self, -1, "netid");
self.id_input = wx.TextCtrl(self, -1, "", size=(100, -1));
self.name_text = wx.StaticText(self, -1, "name");
self.name_input = wx.TextCtrl(self, -1, "", size=(100, -1));
self.size_text = wx.StaticText(self, -1, "size selection");
self.size_selection = wx.RadioBox(self, -1,
choices = self.valid_sizes,
style = wx.RA_SPECIFY_ROWS
);
self.submit_button = wx.Button(self, SUBMIT_BUTTON, "Submit Order");
# put the controls into a grid
self.ctrl_sizer.Add(self.instruction_text, (0, 0),
span=(1, 4), flag=wx.EXPAND);
self.ctrl_sizer.Add(self.id_text, (1, 0), flag=wx.EXPAND);
self.ctrl_sizer.Add(self.name_text, (1, 1), flag=wx.EXPAND);
self.ctrl_sizer.Add(self.size_text, (1, 2), flag=wx.EXPAND);
self.ctrl_sizer.Add(self.id_input, (2, 0), flag=wx.HORIZONTAL);
self.ctrl_sizer.Add(self.name_input, (2, 1), flag=wx.HORIZONTAL);
self.ctrl_sizer.Add(self.size_selection, (2, 2), flag=wx.EXPAND);
self.ctrl_sizer.Add(self.submit_button, (2, 3), flag=wx.HORIZONTAL);
self.SetSizer(self.ctrl_sizer);
self.ctrl_sizer.Fit(self);
# register event handling functions
wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout);
wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit);
wx.EVT_BUTTON(self, SUBMIT_BUTTON, self.OnSubmit);
def OnAbout(self, evt):
return;
def OnExit(self, evt):
if(self.write_file):
self.write_file.close();
self.Close();
def OnSubmit(self, evt):
# build a tab-delimited-text line of the data and write it
save_fields = [self.id_input.GetValue(),
self.name_input.GetValue(),
self.size_selection.GetStringSelection()];
save_str = "\t".join(save_fields);
# ask for validation before we save
dialog_str = "Are you sure this is correct?" + \
"\n Netid: " + save_fields[0] + \
"\n Name: " + save_fields[1] + \
"\n Size: " + save_fields[2];
if(wx.MessageBox(dialog_str, "Confirm Order",
wx.YES_NO | wx.ICON_EXCLAMATION)
== wx.YES):
# write it out and flush the buffer to make sure it's on disk
self.write_file.write(save_str + "\n");
self.write_file.flush();
wx.MessageBox("Your order has been saved. Thanks!");
# reset the controls for the next user
self.id_input.SetValue('');
self.name_input.SetValue('');
self.size_selection.SetSelection(0);
class pyReg2App(wx.App):
def OnInit(self):
main_frame = regFrame(None, "Senior Jacket Registration");
self.SetTopWindow(main_frame);
main_frame.Show(True);
return True;
reg_app = pyReg2App(redirect=False);
reg_app.MainLoop();
# END CODE 2 1565
I have updated my script to use wx.RadioButton instead, which works
perfectly on my mac again, but now the submit button doesn't show up on
the pc and I can't click in the netid field on the pc either. any
ideas?
# BEGIN CODE
import wx;
SUBMIT_BUTTON = wx.ID_HIGHEST + 10;
class regFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title,
pos=(100, 100), size=(800, 600));
fileDialog = wx.FileDialog(self, "Select a file to which to write",
style = wx.SAVE | wx.OVERWRITE_PROMPT,
wildcard="*.txt|Text");
if(fileDialog.ShowModal() != wx.ID_OK):
print "No file specified - closing";
self.Close();
return;
write_file = fileDialog.GetPath();
self.write_file = open(write_file, "a");
# init main frame with menu and status bars
self.panel = wx.Panel ( self, -1 )
menuBar = wx.MenuBar();
fileMenu = wx.Menu();
fileMenu.Append(wx.ID_ABOUT, "&About\tAlt-A", "About this program");
fileMenu.AppendSeparator();
fileMenu.Append(wx.ID_EXIT, "&Quit\tAlt-Q", "Quit this program");
menuBar.Append(fileMenu, "&File");
self.SetMenuBar(menuBar);
self.CreateStatusBar();
self.ctrl_sizer = wx.GridBagSizer(5, 15);
# build the controls
instructions = " Enter your netid and size in the " + \
"boxes below and press the 'Submit Order' button to place " + \
"your order.";
self.instruction_text = wx.StaticText(self, -1, instructions);
self.id_text = wx.StaticText(self, -1, " netid");
self.id_input = wx.TextCtrl(self, -1, "", size=(160, -1));
self.size_text = wx.StaticText(self, -1, "size");
self.submit_button = wx.Button(self, SUBMIT_BUTTON, "Submit Order");
# put the controls into a grid
self.ctrl_sizer.Add(self.instruction_text, (0, 0),
span=(1, 3), flag=wx.EXPAND);
self.ctrl_sizer.Add(self.id_text, (1, 0), flag=wx.EXPAND);
self.ctrl_sizer.Add(self.size_text, (1, 1), flag=wx.EXPAND);
self.ctrl_sizer.Add(self.id_input, (2, 0), flag=wx.HORIZONTAL);
# TO MODIFY THE LIST OF SIZES, CHANGE THIS:
self.valid_sizes = ['4XLT', '3XLT', '2XLT', '2XL', 'XLT',
'XL', 'LT', 'L', 'M', 'S', 'XS', 'XXS'];
first_size = 1;
size_count = 0;
self.button_array = [];
for this_size in self.valid_sizes:
this_button = '';
if first_size:
this_button = wx.RadioButton(self.panel, -1, this_size,
style=wx.RB_GROUP);
first_size = 0;
else:
this_button = wx.RadioButton(self.panel, -1, this_size);
self.button_array.append(this_button);
self.ctrl_sizer.Add(this_button, (size_count+2, 1));
size_count += 1;
self.ctrl_sizer.Add(self.submit_button, (2, 2), flag=wx.HORIZONTAL);
self.SetSizer(self.ctrl_sizer);
self.ctrl_sizer.Fit(self);
# register event handling functions
wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout);
wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit);
wx.EVT_BUTTON(self, SUBMIT_BUTTON, self.OnSubmit);
def OnAbout(self, evt):
return;
def OnExit(self, evt):
if(self.write_file):
self.write_file.close();
self.Close();
def OnSubmit(self, evt):
selected_index = -1;
this_index = 0;
for this_button in self.button_array:
if this_button.GetValue():
selected_index = this_index;
this_index += 1;
# make sure the user selected something
if selected_index == -1:
wx.MessageBox("You must select a size to place your order",
"Please select a size",
wx.ICON_EXCLAMATION);
return;
# build a tab-delimited-text line of the data and write it
save_fields = [self.id_input.GetValue(),
self.valid_sizes[selected_index]];
save_str = "\t".join(save_fields);
# ask for validation before we save
dialog_str = "Are you sure this is correct?" + \
"\n Netid: " + save_fields[0] + \
"\n Size: " + save_fields[1];
if(wx.MessageBox(dialog_str, "Confirm Order",
wx.YES_NO | wx.ICON_EXCLAMATION)
== wx.YES):
# write it out and flush the buffer to make sure it's on disk
self.write_file.write(save_str + "\n");
self.write_file.flush();
wx.MessageBox("Your order has been saved. Thanks!");
# reset the controls for the next user
self.id_input.SetValue('');
self.button_array[selected_index].SetValue(0);
class pyReg2App(wx.App):
def OnInit(self):
main_frame = regFrame(None, "Senior Jacket Registration");
self.SetTopWindow(main_frame);
main_frame.Show(True);
return True;
reg_app = pyReg2App(redirect=False);
reg_app.MainLoop();
# END CODE eu************@gmail.com wrote:
I have updated my script to use wx.RadioButton instead, which works
perfectly on my mac again, but now the submit button doesn't show up on
the pc and I can't click in the netid field on the pc either. any
ideas?
I modified the __init__() method of class regFrame from your original
posting to create a wx.Panel as a child of self and then made all the
controls be children of this panel. Your app then seemed to work OK on
Windows XP. Using a wx.Panel to hold the content of a frame is a
standard wxPython idiom. I find reading the wxPython demo source is a
very useful way to learn this sort of thing.
HTH,
-- CMcP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: * ProteanThread * |
last post by:
but depends upon the clique:
...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: David Peach |
last post by:
Hello, hope somebody here can help me... I have a query that lists
defects recorded in a user defined date range. That query is then used
as the source for a Cross Tab query that cross-tabs count...
|
by: Jeff Rodriguez |
last post by:
Here's what I want do:
Have a main daemon which starts up several threads in a Boss-Queue structure.
From those threads, I want them all to sit and watch a queue. Once an entry
goes into the...
|
by: Web Science |
last post by:
Site and Features: http://www.eigensearch.com
Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics,...
|
by: Rob Woodworth |
last post by:
Hi,
I'm having serious problems getting my report to work. I need to
generate a timesheet report which will contain info for one employee between
certain dates (one week's worth of dates). I...
|
by: Simon |
last post by:
Hi All,
An experiment i'm doing requires requires a synchronous cross-domain
request, without using a proxy. I wondered if anyone had any ideas to
help me achieve this.
Below is what I have...
|
by: Bart Van der Donck |
last post by:
Hello,
I'm presenting my new library 'AJAX Cross Domain' - a javascript
extension that allows to perform cross-domain AJAX requests.
http://www.ajax-cross-domain.com/
Any comments or...
|
by: ampo |
last post by:
Hello.
Can anyone help with cross-domain problem?
I have HTML page from server1 that send xmlHTTPRequest to server2.
How can I do it?
Thanks.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
| |