Hi All,
I am new to wxPython.I have made a simple GUI that contains a button and by pressing that button i am calling another .py file…But i am getting error using the command:
top_block.start()
The error is:
AttributeError: ‘module’ object has no attribute ‘start’
The code is as attached.Any improvements in the code are also welcome.
Regards,
Jason
wxgui.py (827 Bytes)
does top_block.py have a start function in it?
···
On Wednesday, June 11, 2014 3:09:56 AM UTC-7, werner wrote:
Hi,
On 6/11/2014 6:49, jason sam wrote:
Hi All,
I am new to wxPython.I have made a simple GUI that contains a button
and by pressing that button i am calling another .py file…But i am
getting error using the command:
top_block.start()
The error is:
AttributeError: ‘module’ object has no attribute ‘start’
What is the code in top_block?
Werner
The top_block.py is as attached.
top_block.py (690 Bytes)
Hi Jason,
The top_block.py is as attached.
In your base file you do:
def Execute(self,event):
import top_block
top_block.start()
Where do you have the 'start' method or function in top_block.py?
What do you actually want to accomplish?
My guess is you want to have two or more frames in your application, for that you can just do something like this:
def Execute(self,event):
import top_block # normally you would move this to the beginning of your module
self.aNewFrame = top_block.MyFrame(self, title='Bitmaps')
self.aNewFrame.Show()
In other words your application should only have one instance of wx.App
Werner
···
On 6/12/2014 5:34, jason sam wrote:
Hi Werner,
Yes, that is what i was trying to do…Another thing how can i make the previous frame invisible when new frame is shown?
Regards,
Jason
···
On Thu, Jun 12, 2014 at 11:19 AM, Werner wernerfbd@gmx.ch wrote:
Hi Jason,
On 6/12/2014 5:34, jason sam wrote:
The top_block.py is as attached.
In your base file you do:
def Execute(self,event):
import top_block
top_block.start()
Where do you have the ‘start’ method or function in top_block.py?
What do you actually want to accomplish?
My guess is you want to have two or more frames in your application, for that you can just do something like this:
def Execute(self,event):
import top_block # normally you would move this to the beginning of your module
self.aNewFrame = top_block.MyFrame(self, title='Bitmaps')
self.aNewFrame.Show()
In other words your application should only have one instance of wx.App
Werner
–
You received this message because you are subscribed to a topic in the Google Groups “wxPython-users” group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/MLMjUHfqEbU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Jason,
Hi Werner,
Yes, that is what i was trying to do..Another thing how can i make the
previous frame invisible when new frame is shown?
that would be:
frame.Hide()
or
frame.Show(False)
You can find this in the documentation:
http://docs.wxwidgets.org/2.9/classwx_frame.html
These are the wxWidgets documentation for 2.9, note that as wx.Frame inherits from wx.Window you will find Show/Hide methods in the doc for wx.Window
I personally prefer to use the wxPython Phoenix (which is still in development) documentation, but you have to be aware that things are not exactly the same if you use wxPython 3.0 (classic) or earlier.
http://wxpython.org/Phoenix/docs/html/Window.html
Some of the changes are documented here:
http://wxpython.org/Phoenix/docs/html/classic_vs_phoenix.html
Werner
···
On 6/12/2014 9:30, jason sam wrote:
Thank you Werner for your guidance!
···
On Thu, Jun 12, 2014 at 1:11 PM, Werner wernerfbd@gmx.ch wrote:
Hi Jason,
On 6/12/2014 9:30, jason sam wrote:
Hi Werner,
Yes, that is what i was trying to do…Another thing how can i make the
previous frame invisible when new frame is shown?
that would be:
frame.Hide()
or
frame.Show(False)
You can find this in the documentation:
http://docs.wxwidgets.org/2.9/classwx_frame.html
These are the wxWidgets documentation for 2.9, note that as wx.Frame inherits from wx.Window you will find Show/Hide methods in the doc for wx.Window
I personally prefer to use the wxPython Phoenix (which is still in development) documentation, but you have to be aware that things are not exactly the same if you use wxPython 3.0 (classic) or earlier.
http://wxpython.org/Phoenix/docs/html/Window.html
Some of the changes are documented here:
http://wxpython.org/Phoenix/docs/html/classic_vs_phoenix.html
Werner
–
You received this message because you are subscribed to a topic in the Google Groups “wxPython-users” group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/MLMjUHfqEbU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I think you could try calling top_block.main()
···
On Wednesday, June 11, 2014 8:34:18 PM UTC-7, jason sam wrote:
The top_block.py is as attached.
oh I guess you’d have to create a main function first:
def main():
app = MyApp(False)
app.MainLoop()
if __name__ == "__main__":
main()
···
On Thursday, June 12, 2014 10:48:52 AM UTC-7, Nathan McCorkle wrote:
I think you could try calling top_block.main()
On Wednesday, June 11, 2014 8:34:18 PM UTC-7, jason sam wrote:
The top_block.py is as attached.
Having two wx.App? Not sure that is possible.
Werner
···
Hi,
On 6/12/2014 19:50, Nathan McCorkle wrote:
oh I guess you'd have to create a main function
first:
def main():
app = MyApp(False)
app.MainLoop()
if __name__ == "__main__":
main()
See below.
check the attributes on line 401, what are baseband_freq and
sample_rate containing?
Here a string or Unicode is expected, check out line 248 in forms.py
Line 181 in forms.py is wanting a float for that SetValue but it is
converted to an int.
In general read the exception from bottom up, the error occurs on
the last line shown for each traceback but it might be caused by
something being done higher above. Always check out the lines of
code which are referring to lines in your code and initially ignore
lines which are in the base library (e.g. wx or others you might be
using).
Werner
···
Hi Jason,
sent to list for the archive.
On 6/12/2014 18:55, jason sam wrote:
Hi Werner,
Now i have made amendments to my program and its working
now…but there is a new problem now…I am now calling a
python script generated by GNU Radio Companion(for those who
know about GRC will understand my question better)…when i
press the execute button i get the following error…
Both files are as attached.Is there a different way
to call a script generated by GRC??Actually i want to create a
GUI and then call different GRC files from it.
Form: <class 'gnuradio.wxgui.forms.forms.
text_box'> -> Error translating value:
“<main.MyFrame; proxy of <Swig Object of type
‘wxFrame *’ at 0x30f44a0> >”
bad operand type for abs(): 'MyFrame'
Enter a float with optional scale suffix. E.g., 100.1M
Form: <class 'gnuradio.wxgui.forms.forms.slider'> ->
Error translating value: “<main.MyFrame; proxy of
<Swig Object of type ‘wxFrame *’ at 0x30f44a0> >”
unsupported operand type(s) for -: 'MyFrame' and 'float'
Value should be within slider range
Using Volk machine: avx_64_mmx_orc
Traceback (most recent call last):
File "wxgui.py", line 26, in Execute
self.aNewFrame = uhd_fft.uhd_fft(self)
File "/home/ali/Desktop/WXGUI/uhd_fft.py", line 155, in
init
size=((-1, 400)),
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/fftsink_gl.py”,
line 126, in init
persist_alpha=persist_alpha,
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/fft_window.py”,
line 304, in init
self.update_grid()
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/fft_window.py”,
line 401, in update_grid
baseband_freq - sample_rate/2.0,
TypeError: unsupported operand type(s) for -: 'MyFrame' and
‘float’
Traceback (most recent call last):
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/forms/forms.py”,
line 102, in
widget.Bind(EVT_DATA, lambda x: self._update(x.data))
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/forms/forms.py”,
line 248, in _update
def _update(self, value): self._text_box.SetValue(value);
self._update_color()
File
“/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_controls.py”,
line 1754, in SetValue
return _controls_.TextCtrl_SetValue(*args, **kwargs)
TypeError: String or Unicode type required
Traceback (most recent call last):
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/forms/forms.py”,
line 102, in
widget.Bind(EVT_DATA, lambda x: self._update(x.data))
File
“/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/forms/forms.py”,
line 181, in _update
def _update(self, value):
self._slider.SetValue(int(round(value)))
TypeError: a float is required

oh, hmm, yeah I guess that would need to be in a new process, using subprocess.Popen, passing python.exe and the .py file as the argument
···
On Thursday, June 12, 2014 11:38:12 AM UTC-7, werner wrote:
Hi,
On 6/12/2014 19:50, Nathan McCorkle wrote:
oh I guess you'd have to create a main function
first:
def main():
app = MyApp(False)
app.MainLoop()
if __name__ == "__main__":
main()
Having two wx.App? Not sure that is possible.
Werner