AttributeError: 'module' object has no attribute 'start'

221 views
Skip to first unread message

jason sam

unread,
Jun 11, 2014, 12:49:20 AM6/11/14
to wxpytho...@googlegroups.com
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

Werner

unread,
Jun 11, 2014, 6:09:56 AM6/11/14
to wxpytho...@googlegroups.com
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

Nathan McCorkle

unread,
Jun 11, 2014, 6:34:49 PM6/11/14
to wxpytho...@googlegroups.com
does top_block.py have a start function in it?

jason sam

unread,
Jun 11, 2014, 11:34:18 PM6/11/14
to wxpytho...@googlegroups.com
The top_block.py is as attached.
top_block.py

Werner

unread,
Jun 12, 2014, 2:19:54 AM6/12/14
to wxpytho...@googlegroups.com
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

jason sam

unread,
Jun 12, 2014, 3:31:00 AM6/12/14
to wxpytho...@googlegroups.com
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




--
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.

Werner

unread,
Jun 12, 2014, 4:11:26 AM6/12/14
to wxpytho...@googlegroups.com
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

jason sam

unread,
Jun 12, 2014, 4:14:22 AM6/12/14
to wxpytho...@googlegroups.com
Thank you Werner for your guidance!




Werner

Nathan McCorkle

unread,
Jun 12, 2014, 1:48:52 PM6/12/14
to wxpytho...@googlegroups.com
I think you could try calling top_block.main()

Nathan McCorkle

unread,
Jun 12, 2014, 1:50:04 PM6/12/14
to wxpytho...@googlegroups.com
oh I guess you'd have to create a main function first:

def main():
    app = MyApp(False)
    app.MainLoop()

if __name__ == "__main__":
    main()

Werner

unread,
Jun 12, 2014, 2:38:12 PM6/12/14
to wxpytho...@googlegroups.com
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

Werner

unread,
Jun 13, 2014, 3:11:40 AM6/13/14
to wxPython-users
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..
See below.
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'
check the attributes on line 401, what are baseband_freq and sample_rate containing?
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/forms/forms.py", line 102, in <lambda>
    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
Here a string or Unicode is expected, check out line 248 in forms.py
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gnuradio/wxgui/forms/forms.py", line 102, in <lambda>
    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


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

Nathan McCorkle

unread,
Jun 13, 2014, 4:29:21 PM6/13/14
to wxpytho...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages