Skip to content

Commit 944bfff

Browse files
committed
Menu magic
1 parent 3049ccb commit 944bfff

3 files changed

Lines changed: 76 additions & 3 deletions

File tree

mainwindow.ui

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,16 +604,66 @@
604604
<child>
605605
<object class="tk.Menuitem.Submenu" id="FileMenu">
606606
<property name="label" translatable="yes">File</property>
607+
<child>
608+
<object class="tk.Menuitem.Command" id="FileExit">
609+
<property name="command">quit</property>
610+
<property name="command_id_arg">false</property>
611+
<property name="label" translatable="yes">Exit</property>
612+
<property name="accelerator">Alt+F4</property>
613+
</object>
614+
</child>
607615
</object>
608616
</child>
609617
<child>
610618
<object class="tk.Menuitem.Submenu" id="ViewMenu">
611619
<property name="label" translatable="yes">View</property>
620+
<child>
621+
<object class="tk.Menuitem.Command" id="ViewJoin">
622+
<property name="command">select_tab_join</property>
623+
<property name="command_id_arg">false</property>
624+
<property name="label" translatable="yes">Join Files</property>
625+
<property name="accelerator">Strg+J</property>
626+
</object>
627+
</child>
628+
<child>
629+
<object class="tk.Menuitem.Command" id="ViewSplit">
630+
<property name="command">select_tab_split</property>
631+
<property name="command_id_arg">false</property>
632+
<property name="label" translatable="yes">Split Files</property>
633+
<property name="accelerator">Strg+S</property>
634+
</object>
635+
</child>
636+
<child>
637+
<object class="tk.Menuitem.Command" id="ViewBg">
638+
<property name="command">select_tab_bg</property>
639+
<property name="command_id_arg">false</property>
640+
<property name="label" translatable="yes">Background/Stamp/Number</property>
641+
<property name="accelerator">Strg+B</property>
642+
</object>
643+
</child>
644+
<child>
645+
<object class="tk.Menuitem.Command" id="ViewRotate">
646+
<property name="command">select_tab_rotate</property>
647+
<property name="command_id_arg">false</property>
648+
<property name="label" translatable="yes">Rotate Pages</property>
649+
<property name="accelerator">Strg+R</property>
650+
</object>
651+
</child>
652+
<child>
653+
<object class="tk.Menuitem.Separator" id="ViewSeparator_1" />
654+
</child>
655+
<child>
656+
<object class="tk.Menuitem.Command" id="ViewProtection">
657+
<property name="command_id_arg">false</property>
658+
<property name="label" translatable="yes">Show Document Protection</property>
659+
<property name="accelerator">Strg+P</property>
660+
</object>
661+
</child>
612662
</object>
613663
</child>
614664
<child>
615-
<object class="tk.Menuitem.Submenu" id="EditMenu">
616-
<property name="label" translatable="yes">Edit</property>
665+
<object class="tk.Menuitem.Submenu" id="HelpMenu">
666+
<property name="label" translatable="yes">Help</property>
617667
</object>
618668
</child>
619669
</object>

pypdfbuilder.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,39 @@ def __init__(self):
241241
self.builder.add_from_file(os.path.join(CURRENT_DIR, 'mainwindow.ui'))
242242

243243
self.mainwindow = self.builder.get_object('mainwindow')
244+
self.notebook = self.builder.get_object('AppNotebook')
245+
self.tabs = {
246+
'join': self.builder.get_object('JoinFrame'),
247+
'split': self.builder.get_object('SplitFrame'),
248+
'bg': self.builder.get_object('BgFrame'),
249+
'rotate': self.builder.get_object('RotateFrame'),
250+
}
251+
self.mainwindow.bind_all('<Control-j>', self.select_tab_join)
252+
self.mainwindow.bind_all('<Control-s>', self.select_tab_split)
253+
self.mainwindow.bind_all('<Control-b>', self.select_tab_bg)
254+
self.mainwindow.bind_all('<Control-r>', self.select_tab_rotate)
244255
self.mainmenu = self.builder.get_object('MainMenu')
245256
self.mainwindow.config(menu=self.mainmenu)
246257

247258
self.builder.connect_callbacks(self)
248259

260+
# Todo get pickled data: last directory visited by user
249261
self.__current_dir = USER_DIR
250262

251263
self.jointab = JoinTabManager(self)
252264
self.splittab = SplitTabManager(self)
253265
self.rotatetab = RotateTabManager(self)
254266

267+
# boy oh boy if there's anyway to do these callsbacks more elegantly, please let me gain that knowledge!
268+
def select_tab_join(self, *args, **kwargs):
269+
self.notebook.select(self.tabs['join'])
270+
def select_tab_split(self, *args, **kwargs):
271+
self.notebook.select(self.tabs['split'])
272+
def select_tab_bg(self, *args, **kwargs):
273+
self.notebook.select(self.tabs['bg'])
274+
def select_tab_rotate(self, *args, **kwargs):
275+
self.notebook.select(self.tabs['rotate'])
276+
255277
def jointab_add_file(self):
256278
self.jointab.add_file()
257279

pypdfbuilder.sublime-project

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
{
55
"path": "."
66
}
7-
]
7+
],
8+
"virtualenv": "/home/thomas/.virtualenvs/pypdfbuilder"
89
}

0 commit comments

Comments
 (0)