Re: Using Gtk.Builder to create a menubar.

2018-04-26 Thread c.buhtz
On 2018-04-26 18:10 Luca Bacci  wrote:
> Hi, I did test it out, here's a working version:

I used your code to create an answer to my StackOverflow question
https://stackoverflow.com/a/50051155/4865723
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Using Gtk.Builder to create a menubar.

2018-04-26 Thread c.buhtz
Thank you very much. Your example works for me but I don't understand
why. ;)

> win.bar

> action_bar = Gio.SimpleAction.new('bar', None)

The name of the action in the XML and the code is different. Why? What
is the system behind it?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Using Gtk.Builder to create a menubar.

2018-04-26 Thread Eric Cashon via gtk-app-devel-list

 
"1. It uses "QMenu" (from Gtk or Gio?) to build a menu structure. I would
prefere this way instead of an XML string. It should be possible
in Python, too? Gtk.Menu or Gio.Menu?"

My understanding of this is that the GMenu is used with the GtkApplication and 
a GtkMenu is used with the "regular" GTK setup. You can use either one in code 
depending on what your program needs and how your program is structured.

Eric

 



___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Using Gtk.Builder to create a menubar.

2018-04-26 Thread Luca Bacci
Hi, I did test it out, here's a working version:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gio

class Window(Gtk.ApplicationWindow):
def __init__(self):
Gtk.Window.__init__(self)
self.set_default_size(200, 100)

#
self.interface_info = """

  

  Foo
  
Bar
win.bar
  

  

"""

builder = Gtk.Builder.new_from_string(self.interface_info, -1)

action_bar = Gio.SimpleAction.new('bar', None)
action_bar.connect('activate', self.on_menu)
self.add_action(action_bar)

menumodel = builder.get_object('TheMenuModel')
menubar = Gtk.MenuBar.new_from_model(menumodel)

# layout
self.layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.layout.pack_start(menubar, False, False, 0)
self.add(self.layout)

self.connect('destroy', Gtk.main_quit)
self.show_all()

def on_menu(self, action, value):
print('on_menu')

if __name__ == '__main__':
win = Window()
Gtk.main()


2018-04-26 11:01 GMT+02:00 Luca Bacci :

> it should be like that (I can't test it right now, try yourself)
>
> #!/usr/bin/env python3
> import gi
> gi.require_version('Gtk', '3.0')
> from gi.repository import Gtk
> from gi.repository import Gio
>
> class Window(Gtk.ApplicationWindow):
> def __init__(self):
> Gtk.Window.__init__(self)
> self.set_default_size(200, 100)
>
> #
> self.interface_info = """
> 
>   
> 
>   Foo
>   
> Bar
> win.bar
>   
> 
>   
> 
> """
>
> builder = Gtk.Builder.new_from_string(self.interface_info, -1)
>
> action_bar = Gio.SimpleAction.new('bar', None)
> action_bar.connect('activate', self.on_menu)
> self.add_action(action_bar)
>
> menumodel = builder.get_object('TheMenuModel')
> menubar = Gtk.MenuBar.new_from_model(menumodel)
>
> # layout
> self.layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
> self.layout.pack_start(menubar, True, True, 0)
> self.add(self.layout)
>
> self.connect('destroy', Gtk.main_quit)
> self.show_all()
>
> def on_menu(self, action, value):
> print('on_menu')
>
> if __name__ == '__main__':
> win = Window()
> Gtk.main()
>
>
> 2018-04-26 10:44 GMT+02:00 Luca Bacci :
>
>> see here:
>>
>> https://wiki.gnome.org/HowDoI/GMenu
>> https://wiki.gnome.org/HowDoI/GAction
>>
>> self.interface_info = """
>>> 
>>>   
>>> 
>>>   Foo
>>>   
>>> Bar
>>>   
>>> 
>>>   
>>> 
>>> """
>>
>>
>> for every  you want to set at least two attributes: "name" and
>> "action". it should be
>>
>> self.interface_info = """
>> 
>>   
>> 
>>   Foo
>>   
>> Bar
>> win.bar
>>   
>> 
>>   
>> 
>> """
>>
>> you get the GMenuModel from the builder
>> menumodel = builder.get_object('TheMenuModel')
>> and you create a menubar widget from the menumodel:
>>
>> menubar = Gtk.MenuBar.new_from_model(menumodel)
>>
>>
>> 2018-04-26 7:10 GMT+02:00 :
>>
>>> Dear Eric,
>>>
>>> thank you for your quick reply.
>>>
>>> > There is a basic setup for the Gtk Application in Python here
>>> > https://developer.gnome.org/gnome-devel-demos/stable/hello-w
>>> orld.py.html.en
>>>
>>> Nice to know. Very helpful.
>>>
>>> > For C you can check
>>> > https://github.com/cecashon/OrderedSetVelociRaptor/blob/mast
>>> er/Misc/Csamples/gtk_app1.c
>>> > which has a menu but doesn't use builder with an application. Maybe
>>> > partial help.
>>>
>>> This code doesn't help me with my problem but brings up two questions.
>>>
>>> 1.
>>> It uses "QMenu" (from Gtk or Gio?) to build a menu structure. I would
>>> prefere this way instead of an XML string. It should be possible
>>> in Python, too? Gtk.Menu or Gio.Menu?
>>>
>>> 2.
>>> It uses " gtk_application_set_menubar()" which I don't want to use.
>>> Because there is no "gtk_application_set_TOOLBAR()"! I need the menubar
>>> and the toolbar as a widget to add them myself to the main window.
>>> Or a " gtk_application_set_toolbar()" - don't understand why there
>>> isn't one.
>>>
>>> It couldn't be so hard to create a menubar and a toolbar with
>>> PyGObject?! Am I the first one who tries this? ;)
>>> ___
>>> gtk-app-devel-list mailing list
>>> gtk-app-devel-list@gnome.org
>>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>>
>>
>>
>

Developing application with GTK3 on WIndows 10

2018-04-26 Thread arkkimede
Following this link https://www.gtk.org/download/windows.php I prepared on
Windows 10/64bit the environment to develop application with GTK3 and Glade
on Windows 10.

(I've installed msys2 / update packages / installing GTK3 libraries /
installing Glade / installing toolchain to develop code ).

I've build a simple application on Ubuntu using GTK3 + glade and it works
perfectly.

Then I ported the same application on Win and I tried to compile like I've
done on UBUNTU.
First of all, during the compilation the option -export-dynamic, suggested
in all the tutorial, is not recognized ad I obtain the following error:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
warning: --export-dynamic is not supported for PE+ targets, did you mean
--export-all-symbols?

If I substitute with --export-all-symbols I obtain gcc.exe: error:
unrecognized command line option '--export-all-symbols'

Than I erase this option.

The compilation end without errors but if I run the executable I obtain the
following errors:

(LAVORO.exe:5684): Gtk-WARNING **: 08:41:50.459: Could not find signal
handler 'on_button1_clicked'. Did you compile with -rdynamic?

(LAVORO.exe:5684): Gtk-WARNING **: 08:41:50.459: Could not find signal
handler 'on_window_main_destroy'. Did you compile with -rdynamic?

(LAVORO.exe:5684): Gtk-WARNING **: 08:41:50.459: Could not find signal
handler 'on_doPlot_clicked'. Did you compile with -rdynamic?

(LAVORO.exe:5684): Gtk-WARNING **: 08:41:50.475: Could not find signal
handler 'on_cbox_changed'. Did you compile with -rdynamic?

(LAVORO.exe:5684): Gtk-WARNING **: 08:41:50.475: Could not find signal
handler 'on_btn_exe_clicked'. Did you compile with -rdynamic?

(LAVORO.exe:5684): Gtk-WARNING **: 08:41:50.475: Could not find signal
handler 'on_btn_quit_clicked'. Did you compile with -rdynamic?

(LAVORO.exe:5684): Gtk-WARNING **: 08:41:50.491: Could not find signal
handler 'on_plotWindow_delete_event'. Did you compile with -rdynamic?

(LAVORO.exe:5684): Gtk-WARNING **: 08:41:50.491: Could not find signal
handler 'on_close_plotWindow_clicked'. Did you compile with -rdynamic?

(LAVORO.exe:5684): Gtk-WARNING **: 08:41:50.506: Could not find signal
handler 'on_plot_draw'. Did you compile with -rdynamic?

Do you understand what is wrong in my installation and do you have an idea
about to solve tis issue?

Could you help me?
Thank you
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Using Gtk.Builder to create a menubar.

2018-04-26 Thread Luca Bacci
it should be like that (I can't test it right now, try yourself)

#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gio

class Window(Gtk.ApplicationWindow):
def __init__(self):
Gtk.Window.__init__(self)
self.set_default_size(200, 100)

#
self.interface_info = """

  

  Foo
  
Bar
win.bar
  

  

"""

builder = Gtk.Builder.new_from_string(self.interface_info, -1)

action_bar = Gio.SimpleAction.new('bar', None)
action_bar.connect('activate', self.on_menu)
self.add_action(action_bar)

menumodel = builder.get_object('TheMenuModel')
menubar = Gtk.MenuBar.new_from_model(menumodel)

# layout
self.layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.layout.pack_start(menubar, True, True, 0)
self.add(self.layout)

self.connect('destroy', Gtk.main_quit)
self.show_all()

def on_menu(self, action, value):
print('on_menu')

if __name__ == '__main__':
win = Window()
Gtk.main()

2018-04-26 10:44 GMT+02:00 Luca Bacci :

> see here:
>
> https://wiki.gnome.org/HowDoI/GMenu
> https://wiki.gnome.org/HowDoI/GAction
>
> self.interface_info = """
>> 
>>   
>> 
>>   Foo
>>   
>> Bar
>>   
>> 
>>   
>> 
>> """
>
>
> for every  you want to set at least two attributes: "name" and
> "action". it should be
>
> self.interface_info = """
> 
>   
> 
>   Foo
>   
> Bar
> win.bar
>   
> 
>   
> 
> """
>
> you get the GMenuModel from the builder
> menumodel = builder.get_object('TheMenuModel')
> and you create a menubar widget from the menumodel:
>
> menubar = Gtk.MenuBar.new_from_model(menumodel)
>
>
> 2018-04-26 7:10 GMT+02:00 :
>
>> Dear Eric,
>>
>> thank you for your quick reply.
>>
>> > There is a basic setup for the Gtk Application in Python here
>> > https://developer.gnome.org/gnome-devel-demos/stable/hello-w
>> orld.py.html.en
>>
>> Nice to know. Very helpful.
>>
>> > For C you can check
>> > https://github.com/cecashon/OrderedSetVelociRaptor/blob/mast
>> er/Misc/Csamples/gtk_app1.c
>> > which has a menu but doesn't use builder with an application. Maybe
>> > partial help.
>>
>> This code doesn't help me with my problem but brings up two questions.
>>
>> 1.
>> It uses "QMenu" (from Gtk or Gio?) to build a menu structure. I would
>> prefere this way instead of an XML string. It should be possible
>> in Python, too? Gtk.Menu or Gio.Menu?
>>
>> 2.
>> It uses " gtk_application_set_menubar()" which I don't want to use.
>> Because there is no "gtk_application_set_TOOLBAR()"! I need the menubar
>> and the toolbar as a widget to add them myself to the main window.
>> Or a " gtk_application_set_toolbar()" - don't understand why there
>> isn't one.
>>
>> It couldn't be so hard to create a menubar and a toolbar with
>> PyGObject?! Am I the first one who tries this? ;)
>> ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>
>
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Using Gtk.Builder to create a menubar.

2018-04-26 Thread Luca Bacci
see here:

https://wiki.gnome.org/HowDoI/GMenu
https://wiki.gnome.org/HowDoI/GAction

self.interface_info = """
> 
>   
> 
>   Foo
>   
> Bar
>   
> 
>   
> 
> """


for every  you want to set at least two attributes: "name" and
"action". it should be

self.interface_info = """

  

  Foo
  
Bar
win.bar
  

  

"""

you get the GMenuModel from the builder
menumodel = builder.get_object('TheMenuModel')
and you create a menubar widget from the menumodel:

menubar = Gtk.MenuBar.new_from_model(menumodel)


2018-04-26 7:10 GMT+02:00 :

> Dear Eric,
>
> thank you for your quick reply.
>
> > There is a basic setup for the Gtk Application in Python here
> > https://developer.gnome.org/gnome-devel-demos/stable/
> hello-world.py.html.en
>
> Nice to know. Very helpful.
>
> > For C you can check
> > https://github.com/cecashon/OrderedSetVelociRaptor/blob/
> master/Misc/Csamples/gtk_app1.c
> > which has a menu but doesn't use builder with an application. Maybe
> > partial help.
>
> This code doesn't help me with my problem but brings up two questions.
>
> 1.
> It uses "QMenu" (from Gtk or Gio?) to build a menu structure. I would
> prefere this way instead of an XML string. It should be possible
> in Python, too? Gtk.Menu or Gio.Menu?
>
> 2.
> It uses " gtk_application_set_menubar()" which I don't want to use.
> Because there is no "gtk_application_set_TOOLBAR()"! I need the menubar
> and the toolbar as a widget to add them myself to the main window.
> Or a " gtk_application_set_toolbar()" - don't understand why there
> isn't one.
>
> It couldn't be so hard to create a menubar and a toolbar with
> PyGObject?! Am I the first one who tries this? ;)
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list