27
27
####################################################################################
28
28
29
29
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
32
32
33
33
def set_geometry_by_parent (widget ,parent ):
34
34
x_offset = int (parent .winfo_rootx ()+ 0.5 * (parent .winfo_width ()- widget .winfo_width ()))
@@ -199,7 +199,6 @@ def hide(self,force_hide=False):
199
199
else :
200
200
self .parent .focus_set ()
201
201
202
-
203
202
self .wait_var .set (True )
204
203
self .parent .config (cursor = "" )
205
204
@@ -320,24 +319,41 @@ def show(self,title='',wait=False):
320
319
super ().show (wait )
321
320
322
321
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
+
323
329
def __init__ (self ,parent ,icon ,bg_color ,pre_show = None ,post_close = None ,min_width = 1000 ,min_height = 600 ):
324
330
super ().__init__ (parent ,icon ,bg_color ,'' ,pre_show ,post_close ,min_width ,min_height )
325
331
326
332
self .message = ''
327
333
328
334
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" )
329
348
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 )
334
350
351
+ ############################################
335
352
self .text .tag_configure ('found' , background = 'yellow' )
336
353
self .text .tag_configure ('found_sel' , background = 'orange' )
337
354
338
- self .text .grid (row = 1 ,column = 0 ,padx = 2 ,pady = 5 )
339
-
340
355
self .area_main .grid_rowconfigure (1 , weight = 1 )
356
+ self .area_main .grid_columnconfigure (0 , weight = 1 )
341
357
342
358
self .cancel_button = Button (self .area_buttons , text = 'Close' , width = 14 , command = super ().hide )
343
359
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
370
386
self .find_lab = Label (self .area_mark )
371
387
self .find_lab .pack (side = 'right' , anchor = 'e' ,padx = 5 ,pady = 5 )
372
388
373
- self .find_lab = Label (self .area_mark )
374
- self .find_lab .pack (side = 'right' , anchor = 'e' ,padx = 5 ,pady = 5 )
375
-
376
389
try :
377
390
self .find_lab .configure (text = 'Mark:' ,compound = 'left' )
378
391
except Exception as e :
379
392
print (e )
380
393
381
394
#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 )
386
397
387
398
self .focus = self .cancel_button
388
399
@@ -406,6 +417,10 @@ def key_press(self,event):
406
417
self .find_key_binding (event )
407
418
elif key in ('Delete' ,'BackSpace' ):
408
419
self .find_key_binding (event )
420
+ elif key == 'Home' :
421
+ self .text .see ('0.0' )
422
+ elif key == 'End' :
423
+ self .text .see ('end' )
409
424
410
425
def find_next_prev (self ,mod ):
411
426
text_search_pool_len = len (self .text_search_pool )
@@ -476,8 +491,6 @@ def show(self,title='',message='',uplabel_text=''):
476
491
self_text .insert ('end' ,message )
477
492
self_text .configure (state = 'disabled' )
478
493
479
- self_text .grid (row = 1 ,column = 0 ,sticky = 'news' ,padx = 5 ,pady = 5 )
480
-
481
494
self .copy_button .configure (state = 'normal' )
482
495
483
496
self .find_key_binding ()
@@ -532,8 +545,8 @@ def yscrollcommand(self,v1,v2):
532
545
if v1 == '0.0' and v2 == '1.0' :
533
546
self .vsb .pack_forget ()
534
547
else :
535
- self .vsb .pack (side = "right" , fill = "y" )
536
548
self .vsb .set (v1 ,v2 )
549
+ self .vsb .pack (side = "right" , fill = "y" )
537
550
538
551
def yview (self ,* args ,** kwargs ):
539
552
self .canvas .yview (* args ,** kwargs )
0 commit comments