UI refresh
All checks were successful
Sanity check / Test Python file (push) Successful in 13s

This commit is contained in:
Nova Cat 2024-12-23 15:15:06 -08:00
parent 1b656964a7
commit 27f760cb79
2 changed files with 53 additions and 80 deletions

View file

@ -3,33 +3,26 @@ gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GdkPixbuf, Gdk
UI_FILE = os.path.dirname(os.path.realpath(__file__)) + "/sweecrypt-gtk.ui"
class GUI:
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self)
window = self.builder.get_object('window')
window.show_all()
def toggle(self, e:bool):
if e:
active = self.builder.get_object('encode').get_property("active")
self.builder.get_object('decode').set_property("active", not active)
else:
active = self.builder.get_object('decode').get_property("active")
self.builder.get_object('encode').set_property("active", not active)
def on_window_destroy(self, window):Gtk.main_quit()
def encode_toggle(self, encode):self.toggle(True)
def decode_toggle(self, decode):self.toggle(False)
def start_clicked(self, start):
encode = self.builder.get_object('encode').get_property("active")
inputted = self.builder.get_object('text').get_property("text")
if encode:
self.builder.get_object('text').set_property("text", sc.encrypt(inputted))
self.builder.get_object('encode').set_property("active", False)
else:
self.builder.get_object('text').set_property("text", sc.decrypt(inputted))
self.builder.get_object('decode').set_property("active", False)
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self)
window = self.builder.get_object('window')
window.show_all()
def on_window_destroy(self, window):Gtk.main_quit()
def toggle(self, checkbox):
checkbox.set_property("label", "Encode" if checkbox.get_property("active") else "Decode")
def start_clicked(self, start):
encode = self.builder.get_object('encode').get_property("active")
inputted = self.builder.get_object('text').get_property("text")
if encode:
self.builder.get_object('text').set_property("text", sc.encrypt(inputted))
self.builder.get_object('encode').set_property("active", False)
else:
self.builder.get_object('text').set_property("text", sc.decrypt(inputted))
self.builder.get_object('encode').set_property("active", True)
def main():
app = GUI()
Gtk.main()
app = GUI()
Gtk.main()
if __name__ == "__main__":
sys.exit(main())
sys.exit(main())

View file

@ -2,21 +2,6 @@
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">edit-copy</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">document-revert</property>
</object>
<object class="GtkImage" id="start">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">document-properties</property>
</object>
<object class="GtkTextBuffer" id="text">
<property name="text" translatable="yes">replace this text with anything
you want to encode or decode.</property>
@ -54,29 +39,39 @@ you want to encode or decode.</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="encode">
<property name="label" translatable="yes">Encode</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image1</property>
<property name="active">True</property>
<signal name="toggled" handler="encode_toggle" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="decode">
<property name="label" translatable="yes">Decode</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image2</property>
<signal name="toggled" handler="decode_toggle" swapped="no"/>
<property name="can-focus">False</property>
<child>
<object class="GtkToggleButton" id="encode">
<property name="label" translatable="yes">Encode</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="active">True</property>
<signal name="toggled" handler="toggle" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="star">
<property name="label" translatable="yes">Start</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="start_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -84,21 +79,6 @@ you want to encode or decode.</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="star">
<property name="label" translatable="yes">Start</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">start</property>
<signal name="clicked" handler="start_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>