update
This commit is contained in:
parent
c69695a9a4
commit
30698d7dd1
4 changed files with 111 additions and 2 deletions
|
@ -2,3 +2,6 @@
|
||||||
|
|
||||||
GTK4 test
|
GTK4 test
|
||||||
https://uzem.pardus.org.tr/enrol/index.php?id=23
|
https://uzem.pardus.org.tr/enrol/index.php?id=23
|
||||||
|
|
||||||
|
### Development Environment
|
||||||
|
run `nix develop -f shell.nix` command in NixOS to get into development environment
|
||||||
|
|
21
shell.nix
Normal file
21
shell.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# shell.nix
|
||||||
|
let
|
||||||
|
# We pin to a specific nixpkgs commit for reproducibility.
|
||||||
|
# Last updated: 2024-04-29. Check for new commits at https://status.nixos.org.
|
||||||
|
# pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/cf8cc1201be8bc71b7cbbbdaf349b22f4f99c7ae.tar.gz") {};
|
||||||
|
pkgs = import <nixpkgs> {};
|
||||||
|
in pkgs.mkShell {
|
||||||
|
packages = [
|
||||||
|
pkgs.gtk4
|
||||||
|
pkgs.gobject-introspection
|
||||||
|
pkgs.pkg-config
|
||||||
|
pkgs.libnotify
|
||||||
|
# pkgs.libadwaita
|
||||||
|
(pkgs.python3.withPackages (python-pkgs: [
|
||||||
|
# select Python packages here
|
||||||
|
# python-pkgs.gi
|
||||||
|
python-pkgs.pycairo
|
||||||
|
python-pkgs.pygobject3
|
||||||
|
]))
|
||||||
|
];
|
||||||
|
}
|
61
src/MainWindow.py
Normal file
61
src/MainWindow.py
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
import gi, sys
|
||||||
|
gi.require_version('Gtk', '4.0')
|
||||||
|
from gi.repository import Gtk, Gio
|
||||||
|
|
||||||
|
class MainWindow(Gtk.ApplicationWindow):
|
||||||
|
def __init__(self, app):
|
||||||
|
super().__init__(application=app)
|
||||||
|
|
||||||
|
self.setup_actions()
|
||||||
|
|
||||||
|
self.setup_window()
|
||||||
|
|
||||||
|
self.setup_headerbar()
|
||||||
|
|
||||||
|
self.setup_ui()
|
||||||
|
|
||||||
|
# == SETUPS ==
|
||||||
|
def setup_actions(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def setup_window(self):
|
||||||
|
self.set_default_size(600, 400)
|
||||||
|
self.set_title("Metin Editörü")
|
||||||
|
|
||||||
|
def setup_headerbar(self):
|
||||||
|
btn_new = Gtk.Button(label="New", icon_name="document-new-symbolic", tooltip_text="Yeni Doküman")
|
||||||
|
btn_open = Gtk.Button(label="Open", icon_name="document-open-symbolic", tooltip_text="Dosya Aç")
|
||||||
|
btn_save = Gtk.Button(label="Save", icon_name="document-save-symbolic", tooltip_text="Kaydet")
|
||||||
|
btn_save_as = Gtk.Button(label="Save As", icon_name="document-save-as-symbolic", tooltip_text="Farklı Kaydet")
|
||||||
|
|
||||||
|
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
|
box.append(btn_new)
|
||||||
|
box.append(btn_open)
|
||||||
|
box.append(btn_save)
|
||||||
|
box.append(btn_save_as)
|
||||||
|
|
||||||
|
headerbar = Gtk.HeaderBar()
|
||||||
|
headerbar.pack_start(box)
|
||||||
|
|
||||||
|
btn_preferences = Gtk.Button(label="Preferences", icon_name="preferences-system-symbolic", tooltip_text="Seçenekler")
|
||||||
|
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
|
box.append(btn_preferences)
|
||||||
|
headerbar.pack_end(box)
|
||||||
|
|
||||||
|
self.set_titlebar(headerbar)
|
||||||
|
|
||||||
|
def setup_ui(self):
|
||||||
|
self.text_view = Gtk.TextView (
|
||||||
|
monospace=True,
|
||||||
|
left_margin=5,
|
||||||
|
right_margin=5,
|
||||||
|
top_margin=5
|
||||||
|
)
|
||||||
|
scrolled_window = Gtk.ScrolledWindow(child=self.text_view)
|
||||||
|
|
||||||
|
self.set_child(scrolled_window)
|
||||||
|
|
||||||
|
# == FUNCTIONS ==
|
||||||
|
# == CALLBACKS ==
|
||||||
|
def on_btn_button_clicked(self, btn):
|
||||||
|
print("Merhaba, evet bu bir buton")
|
24
src/main.py
Executable file
24
src/main.py
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import gi, sys
|
||||||
|
gi.require_version('Gtk', '4.0')
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
from MainWindow import MainWindow
|
||||||
|
|
||||||
|
win = None
|
||||||
|
def on_activate(app):
|
||||||
|
global win
|
||||||
|
|
||||||
|
if not win:
|
||||||
|
win = MainWindow(app)
|
||||||
|
win.present()
|
||||||
|
|
||||||
|
app = Gtk.Application(application_id='com.asandikci.gtk4py')
|
||||||
|
app.connect('activate', on_activate)
|
||||||
|
|
||||||
|
app.set_accels_for_action('win.open', ['<Ctrl>o'])
|
||||||
|
app.set_accels_for_action('win.save', ['<Ctrl>s'])
|
||||||
|
app.set_accels_for_action('win.save-as', ['<Ctrl><Shift>s'])
|
||||||
|
|
||||||
|
app.run(sys.argv)
|
Loading…
Reference in a new issue