pyvguicom 1.0.0__py3-none-any.whl → 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyvguicom might be problematic. Click here for more details.
- pyvguicom/__init__.py +1 -0
- pyvguicom/browsewin.py +10 -11
- pyvguicom/custwidg.py +110 -0
- pyvguicom/pgbox.py +59 -118
- pyvguicom/pgbutt.py +3 -2
- pyvguicom/pgentry.py +183 -22
- pyvguicom/pggui.py +239 -55
- pyvguicom/pgsel.py +441 -0
- pyvguicom/pgsimp.py +34 -265
- pyvguicom/pgtests.py +128 -0
- pyvguicom/pgtextview.py +0 -1
- pyvguicom/pgutils.py +391 -405
- pyvguicom/pgwkit.py +36 -27
- pyvguicom/testbutt.py +27 -25
- pyvguicom/testcust.py +49 -0
- pyvguicom/testentry.py +105 -0
- pyvguicom/testgui.py +125 -0
- pyvguicom/testlettsel.py +98 -0
- pyvguicom/testmsgs.py +142 -0
- pyvguicom/testnums.py +7 -12
- pyvguicom/testroot.py +7 -6
- pyvguicom/testsimple.py +24 -29
- pyvguicom/testtests.py +79 -0
- pyvguicom/testtextv.py +5 -14
- pyvguicom/testutils.py +139 -0
- {pyvguicom-1.0.0.dist-info → pyvguicom-1.1.1.dist-info}/METADATA +11 -5
- pyvguicom-1.1.1.dist-info/RECORD +32 -0
- pyvguicom/sutil.py +0 -344
- pyvguicom-1.0.0.dist-info/RECORD +0 -23
- {pyvguicom-1.0.0.dist-info → pyvguicom-1.1.1.dist-info}/WHEEL +0 -0
- {pyvguicom-1.0.0.dist-info → pyvguicom-1.1.1.dist-info}/top_level.txt +0 -0
pyvguicom/pggui.py
CHANGED
|
@@ -24,6 +24,8 @@ import pgsimp
|
|
|
24
24
|
|
|
25
25
|
IDXERR = "Index is larger than the available number of controls."
|
|
26
26
|
|
|
27
|
+
VERSION = "1.1.1"
|
|
28
|
+
|
|
27
29
|
gui_testmode = 0
|
|
28
30
|
|
|
29
31
|
def randcol():
|
|
@@ -46,6 +48,8 @@ for st in (gtk.STATE_NORMAL, gtk.STATE_INSENSITIVE,
|
|
|
46
48
|
a[st] = gtk.gdk.Color(0, 34251, 0)
|
|
47
49
|
'''
|
|
48
50
|
|
|
51
|
+
def version():
|
|
52
|
+
return VERSION
|
|
49
53
|
|
|
50
54
|
# ------------------------------------------------------------------------
|
|
51
55
|
# Bemd some of the parameters for us
|
|
@@ -118,6 +122,8 @@ class CairoHelper():
|
|
|
118
122
|
|
|
119
123
|
class TextTable(Gtk.Table):
|
|
120
124
|
|
|
125
|
+
''' YTable of text entries '''
|
|
126
|
+
|
|
121
127
|
def __init__(self, confarr, main = None, textwidth = 24):
|
|
122
128
|
GObject.GObject.__init__(self)
|
|
123
129
|
self.texts = []
|
|
@@ -192,7 +198,6 @@ class TextRow(Gtk.HBox):
|
|
|
192
198
|
'''
|
|
193
199
|
pass
|
|
194
200
|
|
|
195
|
-
|
|
196
201
|
def callb(self, arg1):
|
|
197
202
|
#print ("callb arg1", arg1)
|
|
198
203
|
pass
|
|
@@ -285,6 +290,7 @@ class Led(Gtk.DrawingArea):
|
|
|
285
290
|
self.set_size_request(size + border, size + border)
|
|
286
291
|
self.connect("draw", self.draw)
|
|
287
292
|
self.color = color
|
|
293
|
+
self.orgcolor = color
|
|
288
294
|
|
|
289
295
|
def set_color(self, col):
|
|
290
296
|
self.color = col
|
|
@@ -302,17 +308,24 @@ class Led(Gtk.DrawingArea):
|
|
|
302
308
|
#cr.restore()
|
|
303
309
|
|
|
304
310
|
ccc = pgutils.str2float(self.color)
|
|
311
|
+
|
|
312
|
+
cr.set_source_rgba(ccc[0] * 0.5, ccc[1] * 0.5, ccc[2] * 0.5)
|
|
313
|
+
cr.arc(rect.width/2, rect.height/2, rect.width / 2. * .85, 0., 2 * math.pi)
|
|
314
|
+
cr.fill()
|
|
315
|
+
|
|
305
316
|
cr.set_source_rgba(ccc[0] * 0.7, ccc[1] * 0.7, ccc[2] * 0.7)
|
|
306
317
|
cr.arc(rect.width/2, rect.height/2., rect.width/2., 0., 2 * math.pi)
|
|
307
318
|
cr.fill()
|
|
308
319
|
|
|
309
320
|
cr.set_source_rgba(ccc[0], ccc[1], ccc[2])
|
|
310
|
-
cr.arc(rect.width/2, rect.height/2, rect.width / 2. * .
|
|
321
|
+
cr.arc(rect.width/2, rect.height/2, rect.width / 2. * .7, 0., 2 * math.pi)
|
|
311
322
|
cr.fill()
|
|
312
323
|
|
|
313
324
|
# Reflection on the r
|
|
314
|
-
|
|
315
|
-
|
|
325
|
+
cdx = 0.2
|
|
326
|
+
colx = [ min(1, ccc[0] + cdx), min(1, ccc[1] + cdx), min(1, ccc[2] + cdx), ]
|
|
327
|
+
cr.set_source_rgba(*colx)
|
|
328
|
+
cr.arc(rect.width/2+1, rect.height/2, rect.width / 2. * .3, 0., 2 * math.pi)
|
|
316
329
|
cr.fill()
|
|
317
330
|
|
|
318
331
|
# ------------------------------------------------------------------------
|
|
@@ -414,19 +427,23 @@ class WideButt(Gtk.Button):
|
|
|
414
427
|
if callme:
|
|
415
428
|
self.connect("clicked", callme)
|
|
416
429
|
|
|
417
|
-
class FrameTextView(Gtk.
|
|
430
|
+
class FrameTextView(Gtk.Frame):
|
|
418
431
|
|
|
419
432
|
def __init__(self, callme = None):
|
|
420
433
|
|
|
421
434
|
GObject.GObject.__init__(self)
|
|
435
|
+
#super().__init__(self)
|
|
436
|
+
|
|
437
|
+
self.tview = Gtk.TextView()
|
|
438
|
+
#self.tview.set_buffer(Gtk.TextBuffer())
|
|
439
|
+
|
|
422
440
|
self.scroll = Gtk.ScrolledWindow()
|
|
423
441
|
self.scroll.set_size_request(100, 100)
|
|
424
|
-
self.scroll.add_with_viewport(self)
|
|
425
|
-
self.frame = Gtk.Frame()
|
|
426
|
-
self.
|
|
442
|
+
self.scroll.add_with_viewport(self.tview)
|
|
443
|
+
#self.frame = Gtk.Frame()
|
|
444
|
+
self.add(self.scroll)
|
|
427
445
|
|
|
428
|
-
self.
|
|
429
|
-
self.set_size_request(150, 150)
|
|
446
|
+
#self.set_size_request(150, 150)
|
|
430
447
|
ls = self.get_style_context()
|
|
431
448
|
fd = ls.get_font(Gtk.StateFlags.NORMAL)
|
|
432
449
|
#newfd = fd.to_string() + " " + str(fd.get_size() / Pango.SCALE + 4)
|
|
@@ -434,16 +451,16 @@ class FrameTextView(Gtk.TextView):
|
|
|
434
451
|
self.modify_font(Pango.FontDescription("Sans 13"))
|
|
435
452
|
|
|
436
453
|
def append(self, strx):
|
|
437
|
-
buff = self.get_buffer()
|
|
454
|
+
buff = self.tview.get_buffer()
|
|
438
455
|
old = buff.get_text(buff.get_start_iter(), buff.get_end_iter(), False)
|
|
439
|
-
buff.set_text(old +
|
|
456
|
+
buff.set_text(old + strx)
|
|
440
457
|
pgutils.usleep(20)
|
|
441
458
|
#mainwin.statb2.scroll_to_iter(buff.get_end_iter(), 1.0, True, 0.1, 0.1)
|
|
442
459
|
sb = self.scroll.get_vscrollbar()
|
|
443
460
|
sb.set_value(2000000)
|
|
444
461
|
|
|
445
462
|
class Label(Gtk.Label):
|
|
446
|
-
def __init__(self, textm = "", widget = None, tooltip=None, font
|
|
463
|
+
def __init__(self, textm = "", widget = None, tooltip=None, font=None):
|
|
447
464
|
GObject.GObject.__init__(self)
|
|
448
465
|
self.set_text_with_mnemonic(textm)
|
|
449
466
|
if widget:
|
|
@@ -455,7 +472,7 @@ class Label(Gtk.Label):
|
|
|
455
472
|
|
|
456
473
|
class Logo(Gtk.VBox):
|
|
457
474
|
|
|
458
|
-
def __init__(self, labelx, tooltip
|
|
475
|
+
def __init__(self, labelx, tooltip=None, callme=None, font="Times 45"):
|
|
459
476
|
|
|
460
477
|
GObject.GObject.__init__(self)
|
|
461
478
|
|
|
@@ -470,7 +487,7 @@ class Logo(Gtk.VBox):
|
|
|
470
487
|
if callme:
|
|
471
488
|
self.logolab.connect("button-press-event", callme)
|
|
472
489
|
|
|
473
|
-
self.logolab.modify_font(Pango.FontDescription(
|
|
490
|
+
self.logolab.modify_font(Pango.FontDescription(font))
|
|
474
491
|
|
|
475
492
|
#self.pack_start(Spacer(), 0, 0, False)
|
|
476
493
|
self.pack_start(self.logolab, 0, 0, False)
|
|
@@ -490,7 +507,7 @@ class Logo(Gtk.VBox):
|
|
|
490
507
|
|
|
491
508
|
class ListBox(Gtk.TreeView):
|
|
492
509
|
|
|
493
|
-
def __init__(self, limit = -1, colname = ''):
|
|
510
|
+
def __init__(self, callb = None, limit = -1, colname = ''):
|
|
494
511
|
|
|
495
512
|
self.limit = limit
|
|
496
513
|
self.treestore = Gtk.TreeStore(str)
|
|
@@ -509,7 +526,7 @@ class ListBox(Gtk.TreeView):
|
|
|
509
526
|
self.append_column(tvcolumn)
|
|
510
527
|
self.set_activate_on_single_click (True)
|
|
511
528
|
|
|
512
|
-
self.callb =
|
|
529
|
+
self.callb = callb
|
|
513
530
|
self.connect("row-activated", self.tree_sel)
|
|
514
531
|
|
|
515
532
|
def tree_sel(self, xtree, xiter, xpath):
|
|
@@ -653,40 +670,11 @@ def set_testmode(flag):
|
|
|
653
670
|
global gui_testmode
|
|
654
671
|
gui_testmode = flag
|
|
655
672
|
|
|
656
|
-
# ------------------------------------------------------------------------
|
|
657
|
-
# An N pixel horizontal spacer. Defaults to X pix get_center
|
|
658
|
-
|
|
659
|
-
def vspacer(sp = 8):
|
|
660
|
-
lab = Gtk.VBox()
|
|
661
|
-
lab.set_size_request(sp, sp)
|
|
662
|
-
|
|
663
|
-
if gui_testmode:
|
|
664
|
-
lab.override_background_color(
|
|
665
|
-
Gtk.StateFlags.NORMAL, Gdk.RGBA(1, .5, .5) )
|
|
666
|
-
return lab
|
|
667
|
-
|
|
668
|
-
# ------------------------------------------------------------------------
|
|
669
|
-
# An N pixel horizontal spacer. Defaults to X pix get_center
|
|
670
|
-
|
|
671
|
-
class xSpacer(Gtk.HBox):
|
|
672
|
-
|
|
673
|
-
def __init__(self, sp = None):
|
|
674
|
-
GObject.GObject.__init__(self)
|
|
675
|
-
#self.pack_start()
|
|
676
|
-
if gui_testmode:
|
|
677
|
-
col = randcolstr(100, 200)
|
|
678
|
-
self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(col))
|
|
679
|
-
if sp == None:
|
|
680
|
-
sp = 6
|
|
681
|
-
self.set_size_request(sp, sp)
|
|
682
|
-
|
|
683
673
|
# ------------------------------------------------------------------------
|
|
684
674
|
# An N pixel spacer. Defaults to 1 char height / width
|
|
685
675
|
|
|
686
676
|
class Spacer(Gtk.Label):
|
|
687
677
|
|
|
688
|
-
global gui_testmode
|
|
689
|
-
|
|
690
678
|
def __init__(self, sp = 1, title=None, left=False, bottom=False, test=False):
|
|
691
679
|
|
|
692
680
|
GObject.GObject.__init__(self)
|
|
@@ -718,6 +706,35 @@ class Spacer(Gtk.Label):
|
|
|
718
706
|
#self.set_property("label", "wtf")
|
|
719
707
|
#self.set_property("background-set", True)
|
|
720
708
|
|
|
709
|
+
# ------------------------------------------------------------------------
|
|
710
|
+
# An N pixel horizontal spacer. Defaults to X pix get_center
|
|
711
|
+
|
|
712
|
+
class xSpacer(Gtk.HBox):
|
|
713
|
+
|
|
714
|
+
def __init__(self, sp = None):
|
|
715
|
+
GObject.GObject.__init__(self)
|
|
716
|
+
#self.pack_start()
|
|
717
|
+
if gui_testmode:
|
|
718
|
+
col = randcolstr(100, 200)
|
|
719
|
+
self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(col))
|
|
720
|
+
if sp == None:
|
|
721
|
+
sp = 6
|
|
722
|
+
self.set_size_request(sp, sp)
|
|
723
|
+
|
|
724
|
+
# An N pixel vertical spacer. Defaults to X pix get_center
|
|
725
|
+
|
|
726
|
+
class ySpacer(Gtk.VBox):
|
|
727
|
+
|
|
728
|
+
def __init__(self, sp = None):
|
|
729
|
+
GObject.GObject.__init__(self)
|
|
730
|
+
#self.pack_start()
|
|
731
|
+
if gui_testmode:
|
|
732
|
+
col = randcolstr(100, 200)
|
|
733
|
+
self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(col))
|
|
734
|
+
if sp == None:
|
|
735
|
+
sp = 6
|
|
736
|
+
self.set_size_request(sp, sp)
|
|
737
|
+
|
|
721
738
|
# ------------------------------------------------------------------------
|
|
722
739
|
# Added convenience methods
|
|
723
740
|
|
|
@@ -761,13 +778,21 @@ class xHBox(Gtk.HBox):
|
|
|
761
778
|
|
|
762
779
|
class RadioGroup(Gtk.Frame):
|
|
763
780
|
|
|
764
|
-
def __init__(self, rad_arr, call_me):
|
|
781
|
+
def __init__(self, rad_arr, call_me = None, horiz = False):
|
|
765
782
|
|
|
766
783
|
GObject.GObject.__init__(self)
|
|
767
784
|
self.buttons = []
|
|
768
785
|
self.callme = call_me
|
|
769
|
-
|
|
770
|
-
|
|
786
|
+
if horiz:
|
|
787
|
+
vbox6 = Gtk.HBox();
|
|
788
|
+
vbox6.set_spacing(6);
|
|
789
|
+
vbox6.set_border_width(4)
|
|
790
|
+
else:
|
|
791
|
+
vbox6 = Gtk.VBox();
|
|
792
|
+
vbox6.set_spacing(4);
|
|
793
|
+
vbox6.set_border_width(6)
|
|
794
|
+
|
|
795
|
+
|
|
771
796
|
|
|
772
797
|
if gui_testmode:
|
|
773
798
|
self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("#778888"))
|
|
@@ -829,7 +854,6 @@ class RadioGroup(Gtk.Frame):
|
|
|
829
854
|
# Nothing selected ... empty str
|
|
830
855
|
return ""
|
|
831
856
|
|
|
832
|
-
|
|
833
857
|
# Bug fix in Gtk
|
|
834
858
|
|
|
835
859
|
class SeparatorMenuItem(Gtk.SeparatorMenuItem):
|
|
@@ -992,11 +1016,12 @@ class ScrollListBox(Gtk.Frame):
|
|
|
992
1016
|
|
|
993
1017
|
class ComboBox(Gtk.ComboBox):
|
|
994
1018
|
|
|
995
|
-
def __init__(self, init_cont
|
|
1019
|
+
def __init__(self, init_cont, callme = None):
|
|
1020
|
+
|
|
1021
|
+
self.callme = callme
|
|
996
1022
|
|
|
997
1023
|
self.store = Gtk.ListStore(str)
|
|
998
1024
|
Gtk.ComboBox.__init__(self)
|
|
999
|
-
|
|
1000
1025
|
self.set_model(self.store)
|
|
1001
1026
|
cell = Gtk.CellRendererText()
|
|
1002
1027
|
|
|
@@ -1005,9 +1030,6 @@ class ComboBox(Gtk.ComboBox):
|
|
|
1005
1030
|
#cell.set_property("background-set", True)
|
|
1006
1031
|
cell.set_padding(10, 0)
|
|
1007
1032
|
|
|
1008
|
-
if callme:
|
|
1009
|
-
self.connect("changed", callme)
|
|
1010
|
-
|
|
1011
1033
|
#cell.set_property("foreground", "#ffff00")
|
|
1012
1034
|
#cell.set_property("foreground-set", True)
|
|
1013
1035
|
#print("background-set", cell.get_property("background-set"))
|
|
@@ -1038,6 +1060,9 @@ class ComboBox(Gtk.ComboBox):
|
|
|
1038
1060
|
except:
|
|
1039
1061
|
pass
|
|
1040
1062
|
|
|
1063
|
+
if self.callme:
|
|
1064
|
+
self.callme(name)
|
|
1065
|
+
|
|
1041
1066
|
#print("Combo new selection / entry: '%s'" % name)
|
|
1042
1067
|
|
|
1043
1068
|
def delall(self):
|
|
@@ -1317,6 +1342,165 @@ class RCLButt(Gtk.Button):
|
|
|
1317
1342
|
#if self.callme:
|
|
1318
1343
|
# self.callme(arg1)
|
|
1319
1344
|
|
|
1345
|
+
|
|
1346
|
+
# ------------------------------------------------------------------------
|
|
1347
|
+
# Show a regular message:
|
|
1348
|
+
|
|
1349
|
+
def message(strx, parent = None, title = None, icon = Gtk.MessageType.INFO):
|
|
1350
|
+
|
|
1351
|
+
#dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
|
1352
|
+
# icon, Gtk.ButtonsType.CLOSE, strx)
|
|
1353
|
+
|
|
1354
|
+
dialog = Gtk.MessageDialog(title=title, buttons=Gtk.ButtonsType.CLOSE,
|
|
1355
|
+
text=strx, destroy_with_parent=True, modal=True,)
|
|
1356
|
+
|
|
1357
|
+
if parent:
|
|
1358
|
+
dialog.set_transient_for(parent)
|
|
1359
|
+
|
|
1360
|
+
if title:
|
|
1361
|
+
dialog.set_title(title)
|
|
1362
|
+
else:
|
|
1363
|
+
dialog.set_title("Message")
|
|
1364
|
+
|
|
1365
|
+
# Close dialog on user response
|
|
1366
|
+
dialog.connect("response", lambda d, r: d.destroy())
|
|
1367
|
+
dialog.show_all()
|
|
1368
|
+
return dialog.run()
|
|
1369
|
+
|
|
1370
|
+
def yes_no(message, title = "Question", parent=None, default="Yes"):
|
|
1371
|
+
|
|
1372
|
+
dialog = Gtk.MessageDialog(title=title)
|
|
1373
|
+
|
|
1374
|
+
img = Gtk.Image.new_from_stock(Gtk.STOCK_DIALOG_QUESTION, Gtk.IconSize.DIALOG)
|
|
1375
|
+
dialog.set_image(img)
|
|
1376
|
+
dialog.set_markup(message)
|
|
1377
|
+
|
|
1378
|
+
if default == "Yes":
|
|
1379
|
+
dialog.set_default_response(Gtk.ResponseType.YES)
|
|
1380
|
+
dialog.add_button("_Yes", Gtk.ResponseType.YES)
|
|
1381
|
+
dialog.add_button("_No", Gtk.ResponseType.NO)
|
|
1382
|
+
else:
|
|
1383
|
+
dialog.set_default_response(Gtk.ResponseType.NO)
|
|
1384
|
+
dialog.add_button("_No", Gtk.ResponseType.NO)
|
|
1385
|
+
dialog.add_button("_Yes", Gtk.ResponseType.YES)
|
|
1386
|
+
|
|
1387
|
+
if parent:
|
|
1388
|
+
dialog.set_transient_for(parent)
|
|
1389
|
+
|
|
1390
|
+
def _yn_key(win, event, cancel):
|
|
1391
|
+
#print("_y_n key", event.keyval)
|
|
1392
|
+
if event.keyval == Gdk.KEY_y or \
|
|
1393
|
+
event.keyval == Gdk.KEY_Y:
|
|
1394
|
+
win.response(Gtk.ResponseType.YES)
|
|
1395
|
+
if event.keyval == Gdk.KEY_n or \
|
|
1396
|
+
event.keyval == Gdk.KEY_N:
|
|
1397
|
+
win.response(Gtk.ResponseType.NO)
|
|
1398
|
+
#if cancel:
|
|
1399
|
+
# if event.keyval == Gdk.KEY_c or \
|
|
1400
|
+
# event.keyval == Gdk.KEY_C:
|
|
1401
|
+
# win.response(Gtk.ResponseType.CANCEL)
|
|
1402
|
+
|
|
1403
|
+
dialog.connect("key-press-event", _yn_key, 0)
|
|
1404
|
+
# Fri 03.May.2024 destroyed return value
|
|
1405
|
+
#dialog.connect("response", lambda d, r: d.destroy())
|
|
1406
|
+
dialog.show_all()
|
|
1407
|
+
response = dialog.run()
|
|
1408
|
+
dialog.destroy()
|
|
1409
|
+
#print("response", response, resp2str(response))
|
|
1410
|
+
|
|
1411
|
+
# Convert all other responses to default
|
|
1412
|
+
if response == Gtk.ResponseType.REJECT or \
|
|
1413
|
+
response == Gtk.ResponseType.CLOSE or \
|
|
1414
|
+
response == Gtk.ResponseType.DELETE_EVENT:
|
|
1415
|
+
response = Gtk.ResponseType.NO
|
|
1416
|
+
|
|
1417
|
+
# Cancel means no
|
|
1418
|
+
#if default == "Yes":
|
|
1419
|
+
# response = Gtk.ResponseType.YES
|
|
1420
|
+
#else:
|
|
1421
|
+
# response = Gtk.ResponseType.NO
|
|
1422
|
+
|
|
1423
|
+
return response
|
|
1424
|
+
|
|
1425
|
+
# ------------------------------------------------------------------------
|
|
1426
|
+
|
|
1427
|
+
def yes_no_cancel(message, title="Question", default="Yes"):
|
|
1428
|
+
|
|
1429
|
+
dialog = Gtk.MessageDialog(title=title)
|
|
1430
|
+
|
|
1431
|
+
if default == "Yes":
|
|
1432
|
+
dialog.set_default_response(Gtk.ResponseType.YES)
|
|
1433
|
+
dialog.add_button("_Yes", Gtk.ResponseType.YES)
|
|
1434
|
+
dialog.add_button("_No", Gtk.ResponseType.NO)
|
|
1435
|
+
dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
|
|
1436
|
+
elif default == "No":
|
|
1437
|
+
dialog.set_default_response(Gtk.ResponseType.NO)
|
|
1438
|
+
dialog.add_button("_No", Gtk.ResponseType.NO)
|
|
1439
|
+
dialog.add_button("_Yes", Gtk.ResponseType.YES)
|
|
1440
|
+
dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
|
|
1441
|
+
else:
|
|
1442
|
+
dialog.set_default_response(Gtk.ResponseType.CANCEL)
|
|
1443
|
+
dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
|
|
1444
|
+
dialog.add_button("_Yes", Gtk.ResponseType.YES)
|
|
1445
|
+
dialog.add_button("_No", Gtk.ResponseType.NO)
|
|
1446
|
+
|
|
1447
|
+
img = Gtk.Image.new_from_stock(Gtk.STOCK_DIALOG_QUESTION, Gtk.IconSize.DIALOG)
|
|
1448
|
+
dialog.set_image(img)
|
|
1449
|
+
dialog.set_markup(message)
|
|
1450
|
+
|
|
1451
|
+
def _yn_keyc(win, event):
|
|
1452
|
+
#print("key:", event)
|
|
1453
|
+
if event.keyval == Gdk.KEY_y or \
|
|
1454
|
+
event.keyval == Gdk.KEY_Y:
|
|
1455
|
+
win.response(Gtk.ResponseType.YES)
|
|
1456
|
+
if event.keyval == Gdk.KEY_n or \
|
|
1457
|
+
event.keyval == Gdk.KEY_N:
|
|
1458
|
+
win.response(Gtk.ResponseType.NO)
|
|
1459
|
+
if event.keyval == Gdk.KEY_c or \
|
|
1460
|
+
event.keyval == Gdk.KEY_C:
|
|
1461
|
+
win.response(Gtk.ResponseType.CANCEL)
|
|
1462
|
+
|
|
1463
|
+
dialog.connect("key-press-event", _yn_keyc)
|
|
1464
|
+
dialog.show_all()
|
|
1465
|
+
response = dialog.run()
|
|
1466
|
+
|
|
1467
|
+
# Convert all other responses to cancel
|
|
1468
|
+
if response == Gtk.ResponseType.CANCEL or \
|
|
1469
|
+
response == Gtk.ResponseType.REJECT or \
|
|
1470
|
+
response == Gtk.ResponseType.CLOSE or \
|
|
1471
|
+
response == Gtk.ResponseType.DELETE_EVENT:
|
|
1472
|
+
response = Gtk.ResponseType.CANCEL
|
|
1473
|
+
|
|
1474
|
+
dialog.destroy()
|
|
1475
|
+
|
|
1476
|
+
#print("yes_no_cancel() result:", response);
|
|
1477
|
+
return response
|
|
1478
|
+
|
|
1479
|
+
def resp2str(resp):
|
|
1480
|
+
|
|
1481
|
+
''' Translate response to string '''
|
|
1482
|
+
|
|
1483
|
+
strx = "None"
|
|
1484
|
+
if resp == Gtk.ResponseType.YES:
|
|
1485
|
+
strx = "Yes"
|
|
1486
|
+
if resp == Gtk.ResponseType.NO:
|
|
1487
|
+
strx = "No"
|
|
1488
|
+
if resp == Gtk.ResponseType.OK:
|
|
1489
|
+
strx = "OK"
|
|
1490
|
+
if resp == Gtk.ResponseType.CANCEL:
|
|
1491
|
+
strx = "Cancel"
|
|
1492
|
+
if resp == Gtk.ResponseType.NONE:
|
|
1493
|
+
strx = "None"
|
|
1494
|
+
if resp == Gtk.ResponseType.ACCEPT:
|
|
1495
|
+
strx = "Accept"
|
|
1496
|
+
if resp == Gtk.ResponseType.REJECT:
|
|
1497
|
+
strx = "Reject"
|
|
1498
|
+
if resp == Gtk.ResponseType.CLOSE:
|
|
1499
|
+
strx = "CLlose"
|
|
1500
|
+
if resp == Gtk.ResponseType.DELETE_EVENT:
|
|
1501
|
+
strx = "Delete Event"
|
|
1502
|
+
return strx
|
|
1503
|
+
|
|
1320
1504
|
# ------------------------------------------------------------------------
|
|
1321
1505
|
# Highlite test items
|
|
1322
1506
|
|