help with some problems on Tutorial 1 for GladeVcp

More
18 Dec 2013 07:56 - 18 Dec 2013 07:57 #41725 by gww250
I finally got glade installed properly and started following the tutorial at this location: . The URL is gnipsel.com/linuxcnc/gui/gui01b.html
I did a copy and paste of the code but built the glade file from scratch. When I follow the instructions I get the following error messages in the terminal:


user@dell-d610:~$ #!/usr/bin/env python
user@dell-d610:~$
user@dell-d610:~$
user@dell-d610:~$
user@dell-d610:~$ import pygtk

user@dell-d610:~$
user@dell-d610:~$ pygtk.require("2.16")
bash: syntax error near unexpected token `"2.16"'
user@dell-d610:~$
user@dell-d610:~$ import gtk
user@dell-d610:~$
user@dell-d610:~$ import gladevcp.makepins
user@dell-d610:~$
user@dell-d610:~$ from gladevcp.gladebuilder import GladeBuilder
from: can't read /var/mail/gladevcp.gladebuilder
user@dell-d610:~$
user@dell-d610:~$ import hal
user@dell-d610:~$
user@dell-d610:~$
user@dell-d610:~$
user@dell-d610:~$ class gui_one(object):
bash: syntax error near unexpected token `('
user@dell-d610:~$
user@dell-d610:~$
user@dell-d610:~$
user@dell-d610:~$ def on_MainWindow_destroy(self, widget, data=None):
bash: syntax error near unexpected token `('
user@dell-d610:~$
user@dell-d610:~$ print "quit with cancel"
Warning: unknown mime-type for "quit with cancel" -- using "application/octet-stream"
Error: no such file "quit with cancel"
user@dell-d610:~$
user@dell-d610:~$ gtk.main_quit()
>
>
>
> def on_gtk_quit_activate(self, menuitem, data=None):
bash: syntax error near unexpected token `def'
user@dell-d610:~$
user@dell-d610:~$ print "quit from menu"
Warning: unknown mime-type for "quit from menu" -- using "application/octet-stream"
Error: no such file "quit from menu"
user@dell-d610:~$
user@dell-d610:~$ gtk.main_quit()
>
>
>
> def __init__(self):
bash: syntax error near unexpected token `def'
user@dell-d610:~$
user@dell-d610:~$ self.builder = gtk.Builder()
bash: syntax error near unexpected token `('
user@dell-d610:~$
user@dell-d610:~$ self.builder.add_from_file("gui1.glade")
bash: syntax error near unexpected token `"gui1.glade"'
user@dell-d610:~$
user@dell-d610:~$ halcomp = hal.component("gui01")
bash: syntax error near unexpected token `('
user@dell-d610:~$
user@dell-d610:~$ self.builder.connect_signals(self)
bash: syntax error near unexpected token `self'
user@dell-d610:~$
user@dell-d610:~$ self.window = self.builder.get_object("MainWindow")
bash: syntax error near unexpected token `('
user@dell-d610:~$
user@dell-d610:~$ self.window.show()
>
> panel = gladevcp.makepins.GladePanel( halcomp, "gui1.glade", self.builder, None)
bash: syntax error near unexpected token `panel'
user@dell-d610:~$
user@dell-d610:~$ halcomp.ready()
>
>
>
> if __name__ == "__main__":
>
> app = gui_one()
bash: syntax error near unexpected token `('
user@dell-d610:~$
user@dell-d610:~$ gtk.main()
>

What am I doing wrong?
Last edit: 18 Dec 2013 07:57 by gww250. Reason: url not showing up

Please Log in or Create an account to join the conversation.

More
18 Dec 2013 08:58 #41731 by mhaberler
you obviously pasted python code into a shell window

save the code in a file, say example.py

then run it with

$ python example.py

Please Log in or Create an account to join the conversation.

More
18 Dec 2013 09:14 #41732 by gww250
I tried that first and the terminal screen just flashed and disappeared. The gui didn't show up.

Please Log in or Create an account to join the conversation.

More
18 Dec 2013 09:27 #41733 by gww250
I removed the pygtk require ("2.6") line and it finally ran, sort of. Here is the ouput result:

gui1.py:23: RuntimeWarning: missing handler 'on_window1_destroy'
self.builder.connect_signals(self)
gui1.py:23: RuntimeWarning: missing handler 'on_quit_activate'
self.builder.connect_signals(self)
Traceback (most recent call last):
File "gui1.py", line 30, in <module>
app = gui_one()
File "gui1.py", line 25, in __init__
self.window.show()
AttributeError: 'NoneType' object has no attribute 'show'
user@dell-d610:~/linuxcnc/configs/laser2gui$

Please Log in or Create an account to join the conversation.

More
18 Dec 2013 15:39 #41743 by cmorley
John's turtorial has:
pygtk.require("2.0") which is not the same as 2.16 or 2.6 :)

The last problem you have is most likely that the window in the glade file is not named right.
Default name in GLADE is window1, John's python program expects it to be MainWindow
change one of them.

John you shouldn't be so tricky to newbies :)

Chris M

Please Log in or Create an account to join the conversation.

More
18 Dec 2013 20:54 - 18 Dec 2013 20:58 #41756 by BigJohnT

John's turtorial has:
pygtk.require("2.0") which is not the same as 2.16 or 2.6 :)

The last problem you have is most likely that the window in the glade file is not named right.
Default name in GLADE is window1, John's python program expects it to be MainWindow
change one of them.

John you shouldn't be so tricky to newbies :)

Chris M


Didn't mean to be but if he skipped tutorial 1 then that could lead to some confusion... do I even need the pygtk.require?

Well it looks like I changed back to window1 in almost all places... fixing that now.

JT
Last edit: 18 Dec 2013 20:58 by BigJohnT.

Please Log in or Create an account to join the conversation.

More
18 Dec 2013 21:14 #41758 by BigJohnT
gww250 please refresh any pages from 1-5 where I had the confusion about the MainWindow vs window1. Seems I reverted back calling the main window MainWindow in most places but forgot to change it in some places. Also if you have downloaded any files from 1-5 download the corrected ones.

Thanks
JT

Please Log in or Create an account to join the conversation.

More
19 Dec 2013 00:16 #41774 by gww250
You're right about window1 and MainWindow. I printed out all of the tutorial pages and didn't notice the change so i was using window1 while the code I pasted called for MainWindow. Runs fine now except for the quit button in the menu but I can fix that.
I really appreciate the help. I've been using Linuxcnc for about two years but this is the first I've ever tried to customize a control panel.

Please Log in or Create an account to join the conversation.

More
20 Dec 2013 10:42 #41856 by gww250
Things are moving along nicely. These are great tutorials but I've run into a snag with the python file from part 3b where we create a standalone sim gui. The error occurs at this line:
libdir = os.path.join(BASE, "lib", "python")
And the message simply states : syntax error: invalid syntax
Any ideas?

Please Log in or Create an account to join the conversation.

More
20 Dec 2013 17:13 #41864 by cmorley
It tried the code on Johns page and found no syntax errors.
I didn't have the glade file so can't say if it actually works ..
make sure you typed it right.

Chris M

Please Log in or Create an account to join the conversation.

Moderators: HansU
Time to create page: 0.086 seconds
Powered by Kunena Forum