Python Gtk NGCGUI

More
27 Nov 2012 11:12 #26971 by cmorley
Replied by cmorley on topic Python Gtk NGCGUI
I believe you will only want to reparent the main window. The button window will just be hidden until brought forward.
Or that's what I would try.

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

More
27 Nov 2012 20:24 #26987 by BigJohnT
Replied by BigJohnT on topic Python Gtk NGCGUI
Hmmm, not having any luck. Can you take a peek at the python file and see if you spot anything? As it stands now the screen comes up blank.

Thanks
John
Attachments:

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

More
27 Nov 2012 21:16 #26989 by BigJohnT
Replied by BigJohnT on topic Python Gtk NGCGUI
While I could not get the separate file thing to work I did get this to work all in one file and figured out how to call the dialog from each entry and put the number into the calling entry.



John
Attachments:

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

More
28 Nov 2012 00:18 #27000 by BigJohnT
Replied by BigJohnT on topic Python Gtk NGCGUI
One of the things that bugged me was to have so many functions... one for each button etc. But that is not needed... (slap to forehead). The widget is passed when you press a button or most anything else so just use that to know which widget you just got the signal from. For example I can have 25 data entry fields with unique names and I only need one function to use the keypad thingy with.
  def on_entry_button_press_event(self, widget, data=None):
    self.current_entry = widget
    self.response = self.dialog1.run()

  def on_kb_clicked(self, widget, data=None):
    self.current = self.num_entry.get_text()
    self.current = self.current + widget.get_label()
    self.num_entry.set_text(self.current)

  def on_kb_save_clicked(self, widget, data=None):
    self.current_entry.set_text(self.num_entry.get_text())
    self.num_entry.set_text('')
    self.dialog1.hide()

This is so much better than what I was trying to do before making a function for each key. Some keys with different actions will still have a separate function.

Onwards and forward... next I think is to create a subroutine tab and sort out how to send the generated file to LinuxCNC via the python interface program_open().

John
Attachments:

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

More
29 Nov 2012 21:59 - 29 Nov 2012 22:03 #27079 by BigJohnT
Replied by BigJohnT on topic Python Gtk NGCGUI
So thinking out loud here if you had a generic python code to handle everything normally done and used a standard naming convention then non-programmers could design the GUI and if they followed the naming conventions it would just work!

What do you guys think?

Edit: how would you handle status information with a scheme like this?

John
Last edit: 29 Nov 2012 22:03 by BigJohnT.

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

More
30 Nov 2012 09:30 #27095 by cmorley
Replied by cmorley on topic Python Gtk NGCGUI
Naming conventions for callback signals in glade helps other programmers.
The trick is trying not to reference widgets directly from the base program.
Try to always use the widget object that is passed to you in the callback.
(This is what you discovered above)

It would be so nice if its easier to add subroutines!

Chris M

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

More
02 Dec 2012 09:45 #27119 by BigJohnT
Replied by BigJohnT on topic Python Gtk NGCGUI
I'm a little stuck, I've created a gui and some support files and have installed the py file to /usr/bin, the glade to /usr/share/linuxcnc and all that works fine. When I try and import a file with from gui7 import jog I get an error. I've copied the jog.py file to /usr/share/pyshared/gui7. The most frustrating thing is my gui6 import works...

Thanks
John

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

More
02 Dec 2012 16:00 - 02 Dec 2012 16:01 #27120 by cmorley
Replied by cmorley on topic Python Gtk NGCGUI
I need more info.
What is the error?

what is gui6 and gui7 file folders?
is the command?:
from gui7 import jog


Chris M
Last edit: 02 Dec 2012 16:01 by cmorley.

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

More
02 Dec 2012 19:50 #27124 by BigJohnT
Replied by BigJohnT on topic Python Gtk NGCGUI
gui7 is a copy of gui6

The command is
from gui7 import jog

The error is
Import Error: cannot import name jog

If I change the command to
from gui6 import jog
it works, so I've somehow missed a step and can't figure out what I missed.

From my working directory I do
sudo cp gui7 /usr/bin
sudo cp gui7.glade /usr/share/linuxcnc
sudo cp jog.py /usr/share/pyshared/gui7

Thanks
John

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

More
02 Dec 2012 23:18 #27126 by BigJohnT
Replied by BigJohnT on topic Python Gtk NGCGUI
Turns out I needed to have a file __init__.py that I don't fully understand what that does as well as a symlink...

John

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

Time to create page: 0.155 seconds
Powered by Kunena Forum