def pass_generator(self):
if self.tabs[self.current_page][0]\
.scrolled_window.get_name() != "webview": return True
window = build_window(self, 0, 0)
window.set_titlebar(build_headerbar(_("Password Generator"), None, 1))
entry = make_box("{} (Def: 32) (Max: 99999)".format(_("Password Length")), 5, 1)
button = Gtk.Button(label=_("Generate"))
copy = Gtk.Button(label=_("Copy"))
result = Gtk.TextView()
result.set_top_margin(10)
result.set_left_margin(10)
result.set_wrap_mode(Gtk.WrapMode.WORD)
scrolled_window = Gtk.ScrolledWindow()
scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
scrolled_window.set_size_request(400, 200)
scrolled_window.add(result)
bt_grid = Gtk.Grid()
bt_grid.set_column_spacing(10)
bt_grid.attach(button, 1, 0, 1, 1)
bt_grid.attach(copy, 2, 0, 1, 1)
bt_grid.set_column_homogeneous(True)
grid = Gtk.Grid()
grid.attach(entry, 0, 0, 1, 1)
grid.attach(scrolled_window, 0, 1, 1, 1)
grid.attach(bt_grid, 0, 2, 1, 1)
entry.set_property("margin-bottom", 15)
bt_grid.set_property("margin-top", 15)
grid.set_property("margin", 15)
window.add(grid)
window.show_all()
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
for i in entry:
if type(i) == Gtk.Entry: entry = i
button.connect("clicked", lambda x: pass_generate(entry.get_text(), 32, result))
copy.connect("clicked", lambda x: clipboard.set_text(result.get_buffer().\
get_text(result.get_buffer().get_start_iter(),result.get_buffer().get_end_iter(), False), -1))
评论列表
文章目录