Skip to content

Commit

Permalink
gui and search improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrj committed Jan 3, 2024
1 parent 7f9290a commit 1eee52b
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 86 deletions.
6 changes: 3 additions & 3 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ def get_command(executable,parameters,full_file_path,shell):
return res,res
else:
if not parameters:
res = [executable] + [full_file_path]
res = [executable.strip()] + [full_file_path]
elif PARAM_INDICATOR_SIGN not in parameters:
res = [executable] + parameters.strip().split() + [full_file_path]
res = [executable.strip()] + parameters.strip().split() + [full_file_path]
else:
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]
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]

return res,' '.join(res)

Expand Down
51 changes: 32 additions & 19 deletions src/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
####################################################################################

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

def set_geometry_by_parent(widget,parent):
x_offset = int(parent.winfo_rootx()+0.5*(parent.winfo_width()-widget.winfo_width()))
Expand Down Expand Up @@ -199,7 +199,6 @@ def hide(self,force_hide=False):
else:
self.parent.focus_set()


self.wait_var.set(True)
self.parent.config(cursor="")

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

class TextDialogInfo(GenericDialog):
def text_vsb_set(self,v1,v2):
if v1=='0.0' and v2=='1.0':
self.text_vsb.grid_remove()
else:
self.text_vsb.set(v1,v2)
self.text_vsb.grid()

def __init__(self,parent,icon,bg_color,pre_show=None,post_close=None,min_width=1000,min_height=600):
super().__init__(parent,icon,bg_color,'',pre_show,post_close,min_width,min_height)

self.message = ''

self.uplabel = Label(self.area_main,bg=self.bg_color,relief='groove', bd=2,anchor='w', justify='left')
############################################

scrolled_text_frame = Frame(self.area_main,bg=self.bg_color)
scrolled_text_frame.grid(row=1,column=0,sticky='nsew',padx=2,pady=5)

scrolled_text_frame.grid_rowconfigure(0, weight=1)
scrolled_text_frame.grid_columnconfigure(0, weight=1)

self.text = Text(scrolled_text_frame, bg='white',relief='groove',bd=2)
self.text.grid(row=0, column=0, sticky="nsew")

self.text_vsb = Scrollbar(scrolled_text_frame, command=self.text.yview, orient="vertical")
self.text_vsb.grid(row=0, column=1, sticky="ns")

textwidth=80
self.text = scrolledtext.ScrolledText(self.area_main,relief='groove' , bd=2,bg='white',width = textwidth,takefocus=True)
self.text.frame.config(takefocus=False)
self.text.vbar.config(takefocus=False)
self.text.configure(yscrollcommand=self.text_vsb_set)

############################################
self.text.tag_configure('found', background='yellow')
self.text.tag_configure('found_sel', background='orange')

self.text.grid(row=1,column=0,padx=2,pady=5)

self.area_main.grid_rowconfigure(1, weight=1)
self.area_main.grid_columnconfigure(0, weight=1)

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

self.find_lab=Label(self.area_mark)
self.find_lab.pack(side='right', anchor='e',padx=5,pady=5)

try:
self.find_lab.configure(text='Mark:',compound='left')
except Exception as e:
print(e)

#wypelniacz
self.dummylab1=Label(self.area_dummy, width=22)
self.dummylab2=Label(self.area_dummy, width=8)
self.dummylab1.pack(side='right', anchor='e',padx=5,pady=5)
self.dummylab2.pack(side='right', anchor='e',padx=5,pady=5)
Label(self.area_dummy, width=22,bg=self.bg_color).pack(side='right', anchor='e',padx=5,pady=5)
Label(self.area_dummy, width=8,bg=self.bg_color).pack(side='right', anchor='e',padx=5,pady=5)

self.focus=self.cancel_button

Expand All @@ -406,6 +417,10 @@ def key_press(self,event):
self.find_key_binding(event)
elif key in ('Delete','BackSpace'):
self.find_key_binding(event)
elif key == 'Home':
self.text.see('0.0')
elif key == 'End':
self.text.see('end')

def find_next_prev(self,mod):
text_search_pool_len = len(self.text_search_pool)
Expand Down Expand Up @@ -476,8 +491,6 @@ def show(self,title='',message='',uplabel_text=''):
self_text.insert('end',message)
self_text.configure(state='disabled')

self_text.grid(row=1,column=0,sticky='news',padx=5,pady=5)

self.copy_button.configure(state='normal')

self.find_key_binding()
Expand Down Expand Up @@ -532,8 +545,8 @@ def yscrollcommand(self,v1,v2):
if v1=='0.0' and v2=='1.0':
self.vsb.pack_forget()
else:
self.vsb.pack(side="right", fill="y")
self.vsb.set(v1,v2)
self.vsb.pack(side="right", fill="y")

def yview(self,*args,**kwargs):
self.canvas.yview(*args,**kwargs)
Expand Down
Loading

0 comments on commit 1eee52b

Please sign in to comment.