Skip to content

Commit 1eee52b

Browse files
author
piotrj
committed
gui and search improvements
1 parent 7f9290a commit 1eee52b

File tree

3 files changed

+115
-86
lines changed

3 files changed

+115
-86
lines changed

src/core.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ def get_command(executable,parameters,full_file_path,shell):
183183
return res,res
184184
else:
185185
if not parameters:
186-
res = [executable] + [full_file_path]
186+
res = [executable.strip()] + [full_file_path]
187187
elif PARAM_INDICATOR_SIGN not in parameters:
188-
res = [executable] + parameters.strip().split() + [full_file_path]
188+
res = [executable.strip()] + parameters.strip().split() + [full_file_path]
189189
else:
190-
res = [executable] + [p_elem.replace(PARAM_INDICATOR_SIGN,full_file_path) for p_elem in parameters.replace(f'"{PARAM_INDICATOR_SIGN}"',PARAM_INDICATOR_SIGN).replace(f"'{PARAM_INDICATOR_SIGN}'",PARAM_INDICATOR_SIGN).strip().split() if p_elem]
190+
res = [executable.strip()] + [p_elem.replace(PARAM_INDICATOR_SIGN,full_file_path) for p_elem in parameters.replace(f'"{PARAM_INDICATOR_SIGN}"',PARAM_INDICATOR_SIGN).replace(f"'{PARAM_INDICATOR_SIGN}'",PARAM_INDICATOR_SIGN).strip().split() if p_elem]
191191

192192
return res,' '.join(res)
193193

src/dialogs.py

+32-19
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
####################################################################################
2828

2929
from os import name as os_name
30-
from tkinter import Frame,Label,BooleanVar,DoubleVar,StringVar,scrolledtext,Toplevel,Canvas
31-
from tkinter.ttk import Button,Scrollbar,Progressbar,Checkbutton,Entry,Style
30+
from tkinter import Frame,Label,BooleanVar,DoubleVar,StringVar,Toplevel,Canvas,Text
31+
from tkinter.ttk import Button,Scrollbar,Progressbar,Checkbutton,Entry
3232

3333
def set_geometry_by_parent(widget,parent):
3434
x_offset = int(parent.winfo_rootx()+0.5*(parent.winfo_width()-widget.winfo_width()))
@@ -199,7 +199,6 @@ def hide(self,force_hide=False):
199199
else:
200200
self.parent.focus_set()
201201

202-
203202
self.wait_var.set(True)
204203
self.parent.config(cursor="")
205204

@@ -320,24 +319,41 @@ def show(self,title='',wait=False):
320319
super().show(wait)
321320

322321
class TextDialogInfo(GenericDialog):
322+
def text_vsb_set(self,v1,v2):
323+
if v1=='0.0' and v2=='1.0':
324+
self.text_vsb.grid_remove()
325+
else:
326+
self.text_vsb.set(v1,v2)
327+
self.text_vsb.grid()
328+
323329
def __init__(self,parent,icon,bg_color,pre_show=None,post_close=None,min_width=1000,min_height=600):
324330
super().__init__(parent,icon,bg_color,'',pre_show,post_close,min_width,min_height)
325331

326332
self.message = ''
327333

328334
self.uplabel = Label(self.area_main,bg=self.bg_color,relief='groove', bd=2,anchor='w', justify='left')
335+
############################################
336+
337+
scrolled_text_frame = Frame(self.area_main,bg=self.bg_color)
338+
scrolled_text_frame.grid(row=1,column=0,sticky='nsew',padx=2,pady=5)
339+
340+
scrolled_text_frame.grid_rowconfigure(0, weight=1)
341+
scrolled_text_frame.grid_columnconfigure(0, weight=1)
342+
343+
self.text = Text(scrolled_text_frame, bg='white',relief='groove',bd=2)
344+
self.text.grid(row=0, column=0, sticky="nsew")
345+
346+
self.text_vsb = Scrollbar(scrolled_text_frame, command=self.text.yview, orient="vertical")
347+
self.text_vsb.grid(row=0, column=1, sticky="ns")
329348

330-
textwidth=80
331-
self.text = scrolledtext.ScrolledText(self.area_main,relief='groove' , bd=2,bg='white',width = textwidth,takefocus=True)
332-
self.text.frame.config(takefocus=False)
333-
self.text.vbar.config(takefocus=False)
349+
self.text.configure(yscrollcommand=self.text_vsb_set)
334350

351+
############################################
335352
self.text.tag_configure('found', background='yellow')
336353
self.text.tag_configure('found_sel', background='orange')
337354

338-
self.text.grid(row=1,column=0,padx=2,pady=5)
339-
340355
self.area_main.grid_rowconfigure(1, weight=1)
356+
self.area_main.grid_columnconfigure(0, weight=1)
341357

342358
self.cancel_button=Button(self.area_buttons, text='Close', width=14, command=super().hide )
343359
self.cancel_button.pack(side='right', anchor='e',padx=2,pady=5)
@@ -370,19 +386,14 @@ def __init__(self,parent,icon,bg_color,pre_show=None,post_close=None,min_width=1
370386
self.find_lab=Label(self.area_mark)
371387
self.find_lab.pack(side='right', anchor='e',padx=5,pady=5)
372388

373-
self.find_lab=Label(self.area_mark)
374-
self.find_lab.pack(side='right', anchor='e',padx=5,pady=5)
375-
376389
try:
377390
self.find_lab.configure(text='Mark:',compound='left')
378391
except Exception as e:
379392
print(e)
380393

381394
#wypelniacz
382-
self.dummylab1=Label(self.area_dummy, width=22)
383-
self.dummylab2=Label(self.area_dummy, width=8)
384-
self.dummylab1.pack(side='right', anchor='e',padx=5,pady=5)
385-
self.dummylab2.pack(side='right', anchor='e',padx=5,pady=5)
395+
Label(self.area_dummy, width=22,bg=self.bg_color).pack(side='right', anchor='e',padx=5,pady=5)
396+
Label(self.area_dummy, width=8,bg=self.bg_color).pack(side='right', anchor='e',padx=5,pady=5)
386397

387398
self.focus=self.cancel_button
388399

@@ -406,6 +417,10 @@ def key_press(self,event):
406417
self.find_key_binding(event)
407418
elif key in ('Delete','BackSpace'):
408419
self.find_key_binding(event)
420+
elif key == 'Home':
421+
self.text.see('0.0')
422+
elif key == 'End':
423+
self.text.see('end')
409424

410425
def find_next_prev(self,mod):
411426
text_search_pool_len = len(self.text_search_pool)
@@ -476,8 +491,6 @@ def show(self,title='',message='',uplabel_text=''):
476491
self_text.insert('end',message)
477492
self_text.configure(state='disabled')
478493

479-
self_text.grid(row=1,column=0,sticky='news',padx=5,pady=5)
480-
481494
self.copy_button.configure(state='normal')
482495

483496
self.find_key_binding()
@@ -532,8 +545,8 @@ def yscrollcommand(self,v1,v2):
532545
if v1=='0.0' and v2=='1.0':
533546
self.vsb.pack_forget()
534547
else:
535-
self.vsb.pack(side="right", fill="y")
536548
self.vsb.set(v1,v2)
549+
self.vsb.pack(side="right", fill="y")
537550

538551
def yview(self,*args,**kwargs):
539552
self.canvas.yview(*args,**kwargs)

0 commit comments

Comments
 (0)