gtk-examples-python/handy/2-headerbar.py

52 lines
1.5 KiB
Python
Raw Normal View History

2021-09-03 15:09:59 +03:00
selamun = "aleyküm"
2021-08-30 15:21:49 +03:00
import gi, os
gi.require_version("Gtk", "3.0")
gi.require_version("Handy", "1")
2021-11-28 18:13:18 +03:00
from gi.repository import Gtk, Handy, GLib
2021-08-30 15:21:49 +03:00
Handy.init()
class MyWindow(Handy.Window):
def __init__(self):
super().__init__(title="Hello World")
2021-11-28 18:24:18 +03:00
GLib.set_application_name("Hello World")
GLib.set_prgname('Hello World')
2021-08-30 18:11:48 +03:00
self.set_default_size(500, 300)
2021-08-30 15:21:49 +03:00
# WindowHandle
self.handle = Handy.WindowHandle()
self.add(self.handle)
# Box
2021-08-30 15:28:39 +03:00
self.winbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.VERTICAL)
self.handle.add(self.winbox)
2021-08-30 15:21:49 +03:00
# Headerbar
self.hb = Handy.HeaderBar()
self.hb.set_show_close_button(True)
self.hb.props.title = "HeaderBar Example"
2021-08-30 15:28:39 +03:00
self.winbox.pack_start(self.hb, False, True, 0)
2021-08-30 15:21:49 +03:00
# Label
self.lbl = Gtk.Label()
self.lbl.set_text("Hebele hübele")
self.lbl.set_justify(Gtk.Justification.CENTER)
2021-08-30 15:28:39 +03:00
self.winbox.pack_start(self.lbl, True, True, 0)
2021-08-30 15:21:49 +03:00
2021-09-03 15:09:59 +03:00
# Headerbar button 1
self.button = Gtk.Button()
self.button = Gtk.Button.new_from_icon_name("pan-start-symbolic", Gtk.IconSize.MENU)
self.hb.pack_start(self.button)
# Headerbar button 2
self.button2 = Gtk.Button()
self.button2 = Gtk.Button.new_from_icon_name("pan-end-symbolic", Gtk.IconSize.MENU)
self.hb.pack_start(self.button2)
2021-08-30 15:21:49 +03:00
win = MyWindow()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()