This commit is contained in:
parent
1b656964a7
commit
27f760cb79
2 changed files with 53 additions and 80 deletions
|
@ -3,33 +3,26 @@ gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gtk, GdkPixbuf, Gdk
|
from gi.repository import Gtk, GdkPixbuf, Gdk
|
||||||
UI_FILE = os.path.dirname(os.path.realpath(__file__)) + "/sweecrypt-gtk.ui"
|
UI_FILE = os.path.dirname(os.path.realpath(__file__)) + "/sweecrypt-gtk.ui"
|
||||||
class GUI:
|
class GUI:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.builder = Gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
self.builder.add_from_file(UI_FILE)
|
self.builder.add_from_file(UI_FILE)
|
||||||
self.builder.connect_signals(self)
|
self.builder.connect_signals(self)
|
||||||
window = self.builder.get_object('window')
|
window = self.builder.get_object('window')
|
||||||
window.show_all()
|
window.show_all()
|
||||||
def toggle(self, e:bool):
|
def on_window_destroy(self, window):Gtk.main_quit()
|
||||||
if e:
|
def toggle(self, checkbox):
|
||||||
active = self.builder.get_object('encode').get_property("active")
|
checkbox.set_property("label", "Encode" if checkbox.get_property("active") else "Decode")
|
||||||
self.builder.get_object('decode').set_property("active", not active)
|
def start_clicked(self, start):
|
||||||
else:
|
encode = self.builder.get_object('encode').get_property("active")
|
||||||
active = self.builder.get_object('decode').get_property("active")
|
inputted = self.builder.get_object('text').get_property("text")
|
||||||
self.builder.get_object('encode').set_property("active", not active)
|
if encode:
|
||||||
def on_window_destroy(self, window):Gtk.main_quit()
|
self.builder.get_object('text').set_property("text", sc.encrypt(inputted))
|
||||||
def encode_toggle(self, encode):self.toggle(True)
|
self.builder.get_object('encode').set_property("active", False)
|
||||||
def decode_toggle(self, decode):self.toggle(False)
|
else:
|
||||||
def start_clicked(self, start):
|
self.builder.get_object('text').set_property("text", sc.decrypt(inputted))
|
||||||
encode = self.builder.get_object('encode').get_property("active")
|
self.builder.get_object('encode').set_property("active", True)
|
||||||
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 main():
|
def main():
|
||||||
app = GUI()
|
app = GUI()
|
||||||
Gtk.main()
|
Gtk.main()
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
|
@ -2,21 +2,6 @@
|
||||||
<!-- Generated with glade 3.40.0 -->
|
<!-- Generated with glade 3.40.0 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.24"/>
|
<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">
|
<object class="GtkTextBuffer" id="text">
|
||||||
<property name="text" translatable="yes">replace this text with anything
|
<property name="text" translatable="yes">replace this text with anything
|
||||||
you want to encode or decode.</property>
|
you want to encode or decode.</property>
|
||||||
|
@ -54,29 +39,39 @@ you want to encode or decode.</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToggleButton" id="encode">
|
<object class="GtkBox">
|
||||||
<property name="label" translatable="yes">Encode</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="receives-default">True</property>
|
<child>
|
||||||
<property name="image">image1</property>
|
<object class="GtkToggleButton" id="encode">
|
||||||
<property name="active">True</property>
|
<property name="label" translatable="yes">Encode</property>
|
||||||
<signal name="toggled" handler="encode_toggle" swapped="no"/>
|
<property name="visible">True</property>
|
||||||
</object>
|
<property name="can-focus">True</property>
|
||||||
<packing>
|
<property name="receives-default">True</property>
|
||||||
<property name="expand">False</property>
|
<property name="active">True</property>
|
||||||
<property name="fill">True</property>
|
<signal name="toggled" handler="toggle" swapped="no"/>
|
||||||
<property name="position">1</property>
|
</object>
|
||||||
</packing>
|
<packing>
|
||||||
</child>
|
<property name="expand">False</property>
|
||||||
<child>
|
<property name="fill">True</property>
|
||||||
<object class="GtkToggleButton" id="decode">
|
<property name="position">1</property>
|
||||||
<property name="label" translatable="yes">Decode</property>
|
</packing>
|
||||||
<property name="visible">True</property>
|
</child>
|
||||||
<property name="can-focus">True</property>
|
<child>
|
||||||
<property name="receives-default">True</property>
|
<object class="GtkButton" id="star">
|
||||||
<property name="image">image2</property>
|
<property name="label" translatable="yes">Start</property>
|
||||||
<signal name="toggled" handler="decode_toggle" swapped="no"/>
|
<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>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -84,21 +79,6 @@ you want to encode or decode.</property>
|
||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
Loading…
Reference in a new issue