Popup windows and Glade

More
18 Nov 2013 23:05 - 18 Nov 2013 23:47 #40940 by eszyman
Once I get this going, I'm happy to post some code, but for now I'm have an issue with the "modal" attribute.
Axis, seems not to support it, but can anyone confirm this who has played with pop-up / dialog box windows with Axis?

XML example:
<object class="GtkWindow" id="dialog1">
<property name="modal">True</property> <--Not Working?
Last edit: 18 Nov 2013 23:47 by eszyman.

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

More
19 Nov 2013 00:21 #40944 by newbynobi
Replied by newbynobi on topic Popup windows and Glade
Halo eszyman,

I have not done this with axis, but a popup window is not a gtk window itself.

For my notification widget (see gmoccapy) I make a popup window as follow:
class Notification(gtk.Window):

    def __init__(self):
        gtk.Window.__init__(self)
        self.popup = gtk.Window(gtk.WINDOW_POPUP)
        ...
        ...

Hope that helps.

Norbert
The following user(s) said Thank You: eszyman

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

More
19 Nov 2013 01:29 #40947 by eszyman
Replied by eszyman on topic Popup windows and Glade
Thank you for the information, I'm getting gmoccapy as I type.
I need all the help I can get on the python side of things.
There is a very good chance I'm missing some if not most of the fundamentals here.

But if it's at all relevant, I had similar issues with the GtkDialog object, only in that case it refused to give any window decoration and seemed as if the gtk part was entirely dropped which completely supports what you have wrote.

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

More
19 Nov 2013 03:23 #40948 by newbynobi
Replied by newbynobi on topic Popup windows and Glade
What are you trying to do?

If you do not have fundamental knowledge of Python, you will not be able to handle the code of gmoccapy.

Have you taken a look at the Glade and GUI tutorials?

Norbert

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

More
19 Nov 2013 04:09 - 19 Nov 2013 04:11 #40950 by eszyman
Replied by eszyman on topic Popup windows and Glade
If you are referring to Big John's and the GladeVPC documentation, yes for many hours now! :)
I just want a simple confirmation box, where a button is clicked on my GladeVCP which is loaded on the side of Axis, then on that confirmation box I would like the choice of three options, one of which is the cancel box which simply destroys the dialog, the other two execute either a o word call or a separate python script that is already written. The modal option would have been nice, because I don't want the ability to jog the machine or turn it off once that box is opened up.

I guess it sounds simple enough in nature, but finding the proper way to implement that into Axis seems to be a stretch for the documentation I have been able to find.

More details so other may attempt to follow:
First in the axis ini file:
GLADEVCP = -u my_handler.py  my_sidebar.glade
and also
POSTGUI_HALFILE = glade_postgui.hal
for linking other gladevcp.button#s that show up on the side bar.

Then the glade side bar is created with the glade GUI with a button 'button' that has the following details:
in the Signals tab under GtkButton the following is selected from the "clicked" item in the drop down: "on_button_clicked"
An additional window dialog box is also created as 'dialog1'
All the details are added with my two hal buttons, Defaults, Calibrate, and another plain button Cancel.

Next is to code the my_handler.py file to connect the signals to the now 4 buttons, per the tutorials, however I see no handeler py file referenced in the example you have listed, only a hal file. Seems I am missing the bigger picture with gmoccapy (I'm not even sure where to find your notification snippet).

Anyhow per the tutorials as best as I can follow with my limited python knowledge, I have a simple set of defs written as:
#!/usr/bin/env python
try:
  import pygtk
  pygtk.require('2.0')
except:
  pass
try:
  import gtk
  import gtk.glade
except:
  print('GTK not available')
  sys.exit(1)
class MyCallbacks :
    def on_button_clicked(self,obj,data=None):
        print "this_signal happened, obj=",obj
 	self.response = self.dialog1.show()  
    def on_cancel_clicked(self,obj,data=None):
        self.dialog1.hide()
    def __init__(self):
        gladefile = "my_sidebar.glade"
        self.builder = gtk.Builder()
        self.builder.add_from_file(gladefile)
        self.builder.connect_signals(self)
        self.dialog1 = self.builder.get_object("dialog1")   
def get_handlers(halcomp,builder,useropts):
  return [MyCallbacks ()]
if __name__ == "__main__":
  main = MyCallbacks()
  gtk.main()

Which allows my dialogue to open up and destroy, but the other two hal buttons Defaults and Calibrate do not work as referenced in the postgui hal file:
net calibrate-g53 gladevcp.calibrate <= halui.mdi-command-21
net defaults gladevcp.defaults <= halui.mdi-command-22
Last edit: 19 Nov 2013 04:11 by eszyman.

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

More
19 Nov 2013 06:21 #40953 by newbynobi
Replied by newbynobi on topic Popup windows and Glade
Please read linuxcnc.org/docs/html/gui/gladevcp.html

Especialy chapter 4

Norbert

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

More
19 Nov 2013 08:47 #40954 by andypugh
Replied by andypugh on topic Popup windows and Glade

I had similar issues with the GtkDialog object, only in that case it refused to give any window decoration and seemed as if the gtk part was entirely dropped which completely supports what you have wrote.

I think that when you load a GUI through halcmd loadusr everything below the top-level container is adopted by a new "linuxcnc" parent. The answer might be to simply add an extra parent layer.
The following user(s) said Thank You: eszyman

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

More
19 Nov 2013 09:11 #40955 by mhaberler
Replied by mhaberler on topic Popup windows and Glade
"with Axis" is a bit unclear - I assume you mean a gladevcp tab within Axis

in this case you will likely have issues with popups, for the reasons, see www.linuxcnc.org/docs/devel/html/gui/gla...key_handling_in_axis - this also applies to other aspects of a toplevel window, and popups are related

you can separate the issue simply by running standalone (not as an Axis tab) - if the popup works, this is your problem

if so, the answer is not nice: there is no easy way to make that work with Axis, which uses an outdated UI technology which doesnt suppport such behavior

your best option in this case might be to switch to a pure gladevcp-based UI like gscreen or gmoccapy

- Michael
The following user(s) said Thank You: eszyman

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

More
19 Nov 2013 10:44 #40957 by eszyman
Replied by eszyman on topic Popup windows and Glade
Thank you all for the help. Everything said seems to make good sense.

Andy I had considered that but having limited knowledge, I wasn't sure how to make it happen.
The answer may help someone else, but I have decided to drop the extra o-word function idea and just directly run a python script on the button press, which does indeed work.
My o-word command was calling a python script primarily anyhow so this will just save an extra step.

I can not get the modal option to work, but it was just a nice feature anyhow.
Eventually I would like to go with a gtk environment, but I am scared of the rip environment at the moment in which it is required to run.
Maybe this is not a big deal, but I don't have time to get into making one work for our setup right now anyhow, but the concept is definitely on the down the road plan.

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

More
20 Nov 2013 02:58 #40983 by newbynobi
Replied by newbynobi on topic Popup windows and Glade
To get the master running is as simple as spelling gmoccapy ;-)

Take a look if you like at:

gmoccapy wiki

Norbert

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

Moderators: mhaberlerHansU
Time to create page: 0.133 seconds
Powered by Kunena Forum