INSTALARE:
https://pygobject.readthedocs.io/en/latest/getting_started.html
PRIMA APLICATIE: salut.py si se poate rula cu comanda: python3 salut.py
DOCUMENTATIE:
https://python-gtk-3-tutorial.readthedocs.io/en/latest/
UN EXEMPLU UTIL:
UN TEMPLATE PENTRU APLICATIILE PyGObject:
https://github.com/mhcrnl/PyGObject_Template - se poate descarca in format zip sau cu comanda: $ git clone https://github.com/mhcrnl/PyGObject_Template.git
Contine:
UN PROGRAM SIMPLU DE CONVERSIE A TEMPERATURII CELSIUS IN FAHRENHEIT
https://github.com/mhcrnl/62Grid
02salut.py
RESURSE:
http://hilite.me/
https://pygobject.readthedocs.io/en/latest/getting_started.html
PRIMA APLICATIE: salut.py si se poate rula cu comanda: python3 salut.py
1 2 3 4 5 6 7 8 9 | import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk fereastra = Gtk.Window(title="SALUT!") fereastra.show() fereastra.connect("destroy", Gtk.main_quit) Gtk.main() |
DOCUMENTATIE:
https://python-gtk-3-tutorial.readthedocs.io/en/latest/
UN EXEMPLU UTIL:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk class Fereastra(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Salut") self.button = Gtk.Button(label="Apasa aici!") self.button.connect("clicked", self.on_button_clicked) self.add(self.button) def on_button_clicked(self, widget): print("salut") fereastra = Fereastra() fereastra.show() fereastra.connect("destroy", Gtk.main_quit) Gtk.main() |
UN TEMPLATE PENTRU APLICATIILE PyGObject:
https://github.com/mhcrnl/PyGObject_Template - se poate descarca in format zip sau cu comanda: $ git clone https://github.com/mhcrnl/PyGObject_Template.git
Contine:
- 02salut.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk class Fereastra(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="GTK BOX") self.box = Gtk.Box(spacing=6) self.add(self.box) self.button1 = Gtk.Button(label="salut") self.button1.connect("clicked", self.on_button1_clicked) self.box.pack_start(self.button1, True, True, 0) self.button2 = Gtk.Button(label="la revedere") self.button2.connect("clicked", self.on_button2_clicked) self.box.pack_start(self.button2, True, True, 0) def on_button1_clicked(self, widget): print("SALUT!") def on_button2_clicked(self, widget): print("LA REVEDERE!") fereastra = Fereastra() fereastra.connect("destroy", Gtk.main_quit) fereastra.show_all() Gtk.main() |
- gitpush.sh - actualizeaza codul de pe github ./gitpush.sh
1 2 3 4 5 6 7 | #!/bin/bash DATE=`date` git add . git commit -m "$DATE" git push origin master |
- run.sh - ruleaza aplicatia simplu cu comanda ./run.sh
1 | python3 02salut.py |
UN PROGRAM SIMPLU DE CONVERSIE A TEMPERATURII CELSIUS IN FAHRENHEIT
https://github.com/mhcrnl/62Grid
02salut.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk class Fereastra(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="GTK BOX") self.set_default_size(350, 100) self.grid = Gtk.Grid() self.add(self.grid) self.lb_cel = Gtk.Label("Celsius") self.grid.add(self.lb_cel) self.en_cel = Gtk.Entry() self.grid.attach_next_to(self.en_cel, self.lb_cel, Gtk.PositionType.RIGHT, 1, 1) self.button1 = Gtk.Button(label="About") self.button1.connect("clicked", self.on_button1_clicked) self.grid.attach_next_to(self.button1, self.en_cel, Gtk.PositionType.RIGHT, 1, 1) self.lb_fah = Gtk.Label("Fahrenheit") self.grid.attach(self.lb_fah, 0, 1, 1, 1) self.en_fah = Gtk.Entry() self.grid.attach_next_to(self.en_fah, self.lb_fah, Gtk.PositionType.RIGHT, 1,3) self.button2 = Gtk.Button(label="Calculate") self.button2.connect("clicked", self.on_button2_clicked) self.grid.attach_next_to(self.button2,self.en_fah, Gtk.PositionType.RIGHT, 2, 1) def on_button1_clicked(self, widget): print("SALUT!") dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Acesta este un mesaj informativ") dialog.format_secondary_text("Acest program este un convertor de temp.") dialog.run() dialog.destroy() def on_button2_clicked(self, widget): print("LA REVEDERE!") fahr = float(self.en_cel.get_text())*9/5 + 32 str_fahr = str(fahr) self.en_fah.set_text(str_fahr) fereastra = Fereastra() fereastra.connect("destroy", Gtk.main_quit) fereastra.show_all() Gtk.main() |
RESURSE:
http://hilite.me/
Comentarii
Trimiteți un comentariu