pyvguicom 1.0.1__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/pgtests.py ADDED
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/python
2
+
3
+ # pylint: disable=C0103
4
+ # pylint: disable=C0209
5
+ # pylint: disable=C0321
6
+
7
+ import os, sys, getopt, string, math
8
+ import random, time, traceback, stat
9
+ import platform, datetime
10
+
11
+ # Add the new line twice for more balaced string
12
+
13
+ allcr = " " + "\r" + "\n" + \
14
+ "\r" + "\n"
15
+
16
+ allstr = " " + \
17
+ string.ascii_lowercase + string.ascii_uppercase + \
18
+ string.digits
19
+
20
+ allasc = string.ascii_lowercase + string.ascii_uppercase + \
21
+ string.digits + "_"
22
+ alllett = string.ascii_lowercase + string.ascii_uppercase
23
+ testmode = 0
24
+
25
+ alllett = string.ascii_lowercase + string.ascii_uppercase
26
+
27
+ # ------------------------------------------------------------------------
28
+
29
+ def randascii(lenx):
30
+
31
+ ''' Spew a lot of chars, simulate txt by add ' ' an '\n' '''
32
+
33
+ strx = ""
34
+ for aa in range(lenx):
35
+ ridx = random.randint(0x20, 0x7d)
36
+ rr = chr(ridx)
37
+ strx += str(rr)
38
+ if random.randint(0x00, 40) == 30:
39
+ strx += "\n"
40
+ if random.randint(0x00, 12) == 10:
41
+ strx += " "
42
+ return strx
43
+
44
+ def simname(lenx):
45
+ strx = ""
46
+ lenz = len(alllett)-1
47
+ spidx = random.randint(0, lenx - 4)
48
+ ridx = random.randint(0, len(string.ascii_uppercase)-1)
49
+ strx += string.ascii_uppercase[ridx]
50
+ for aa in range(spidx):
51
+ ridx = random.randint(0, len(string.ascii_lowercase)-1)
52
+ rr = string.ascii_lowercase[ridx]
53
+ strx += str(rr)
54
+ strx += " "
55
+ ridx = random.randint(0, len(string.ascii_uppercase)-1)
56
+ strx += string.ascii_uppercase[ridx]
57
+ for aa in range(lenx - spidx):
58
+ ridx = random.randint(0, len(string.ascii_lowercase)-1)
59
+ rr = string.ascii_lowercase[ridx]
60
+ strx += str(rr)
61
+ return strx
62
+
63
+ def randisodate():
64
+ dd = datetime.datetime.now()
65
+ dd = dd.replace(microsecond=0)
66
+ return dd.isoformat()
67
+
68
+ def randate():
69
+
70
+ ''' Give us a random date in str '''
71
+
72
+ dd = datetime.datetime.now()
73
+ dd = dd.replace(year=random.randint(1980, 2024),
74
+ month=random.randint(1, 12),
75
+ day=random.randint(1, 28),
76
+ hour=0, minute=0, second=0, microsecond=0)
77
+
78
+ return dd.strftime("%Y/%m/%d")
79
+
80
+ # ------------------------------------------------------------------------
81
+ # Get random str
82
+
83
+ def randstr(lenx):
84
+
85
+ strx = ""
86
+ for aa in range(lenx):
87
+ ridx = random.randint(0, len(allstr)-1)
88
+ rr = allstr[ridx]
89
+ strx += str(rr)
90
+
91
+ return strx
92
+
93
+ def randasc(lenx):
94
+
95
+ strx = ""
96
+ for aa in range(lenx):
97
+ ridx = random.randint(0, len(allasc)-1)
98
+ rr = allasc[ridx]
99
+ strx += str(rr)
100
+
101
+ return strx
102
+
103
+ def randlett(lenx):
104
+
105
+ strx = ""
106
+ for aa in range(lenx):
107
+ ridx = random.randint(0, len(alllett)-1)
108
+ rr = alllett[ridx]
109
+ strx += str(rr)
110
+
111
+ return strx
112
+
113
+ # ------------------------------------------------------------------------
114
+ # Random colors
115
+
116
+ def randcol():
117
+ return random.randint(0, 255)
118
+
119
+
120
+ def randcolstr(start = 0, endd = 255):
121
+ rr = random.randint(start, endd)
122
+ gg = random.randint(start, endd)
123
+ bb = random.randint(start, endd)
124
+ strx = "#%02x%02x%02x" % (rr, gg, bb)
125
+ return strx
126
+
127
+ # EOF
128
+
pyvguicom/pgutils.py CHANGED
@@ -4,10 +4,12 @@
4
4
  # pylint: disable=C0209
5
5
  # pylint: disable=C0321
6
6
 
7
- import os, sys, getopt, string, math, warnings
7
+ import os, sys, getopt, string, math
8
8
  import random, time, traceback, stat
9
9
  import platform
10
10
 
11
+ #import warmings
12
+
11
13
  if sys.version_info.major < 3:
12
14
  pass
13
15
  else:
@@ -22,148 +24,7 @@ gi.require_version("Gtk", "3.0")
22
24
  from gi.repository import Gtk
23
25
  from gi.repository import Gdk
24
26
  from gi.repository import GObject
25
-
26
- # Add the new line twice for more balaced string
27
-
28
- allcr = " " + "\r" + "\n" + \
29
- "\r" + "\n"
30
-
31
- #string.punctuation +
32
-
33
- allstr = " " + \
34
- string.ascii_lowercase + string.ascii_uppercase + \
35
- string.digits
36
-
37
- allasc = string.ascii_lowercase + string.ascii_uppercase + \
38
- string.digits + "_"
39
- alllett = string.ascii_lowercase + string.ascii_uppercase
40
- testmode = 0
41
-
42
- # -----------------------------------------------------------------------
43
- # Sleep just a little, but allow the system to breed
44
-
45
- def usleep2(msec):
46
-
47
- if sys.version_info[0] < 3 or \
48
- (sys.version_info[0] == 3 and sys.version_info[1] < 3):
49
- timefunc = time.clock
50
- else:
51
- timefunc = time.process_time
52
-
53
- got_clock = timefunc() + float(msec) / 1000
54
- #print( got_clock)
55
- while True:
56
- if timefunc() > got_clock:
57
- break
58
- #print ("Sleeping")
59
- Gtk.main_iteration_do(False)
60
-
61
- # -----------------------------------------------------------------------
62
- # Pull up a message box
63
-
64
- def message2(strx, title = "Dialog", parent=None):
65
-
66
- dialog = Gtk.MessageDialog()
67
- # Close dialog on user response
68
- dialog.add_button("Close", Gtk.ButtonsType.CLOSE)
69
- if title:
70
- dialog.set_title(title)
71
- #box = dialog.get_content_area()
72
- #box.add(Gtk.Label(strx))
73
- dialog.set_markup(strx)
74
- if parent:
75
- dialog.set_transient_for(parent)
76
- dialog.connect ("response", lambda d, r: d.destroy())
77
- dialog.show_all()
78
-
79
- def yes_no2(message, title = "Question", parent=None):
80
-
81
- dialog = Gtk.MessageDialog()
82
- if title:
83
- dialog.set_title(title)
84
- dialog.add_button("_Yes", Gtk.ResponseType.YES)
85
- dialog.add_button("_No", Gtk.ResponseType.NO)
86
- dialog.set_markup(message)
87
- img = Gtk.Image.new_from_stock(Gtk.STOCK_DIALOG_QUESTION, Gtk.IconSize.DIALOG)
88
- dialog.set_image(img)
89
- if parent:
90
- dialog.set_transient_for(parent)
91
- dialog.connect("key-press-event", yn_key, 0)
92
- #dialog.connect ("response", lambda d, r: d.destroy())
93
- dialog.show_all()
94
- response = dialog.run()
95
- dialog.destroy()
96
-
97
- return response
98
-
99
- # ------------------------------------------------------------------------
100
- # Do dialog
101
-
102
- def yes_no_cancel2(message, title = "Question", cancel = True):
103
-
104
- warnings.simplefilter("ignore")
105
-
106
- dialog = Gtk.Dialog(title,
107
- None,
108
- Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT)
109
-
110
- dialog.set_default_response(Gtk.ResponseType.YES)
111
- dialog.set_position(Gtk.WindowPosition.CENTER)
112
-
113
- sp = " "
114
- label = Gtk.Label(message)
115
- label2 = Gtk.Label(sp); label3 = Gtk.Label(sp)
116
- label2a = Gtk.Label(sp); label3a = Gtk.Label(sp)
117
-
118
- hbox = Gtk.HBox()
119
-
120
- hbox.pack_start(label2, 0, 0, 0)
121
- hbox.pack_start(label, 1, 1, 0)
122
- hbox.pack_start(label3, 0, 0, 0)
123
-
124
- dialog.vbox.pack_start(label2a, 0, 0, 0)
125
- dialog.vbox.pack_start(hbox, 0, 0, 0)
126
- dialog.vbox.pack_start(label3a, 0, 0, 0)
127
-
128
- dialog.add_button("_Yes", Gtk.ResponseType.YES)
129
- dialog.add_button("_No", Gtk.ResponseType.NO)
130
-
131
- if cancel:
132
- dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
133
-
134
- dialog.connect("key-press-event", _yn_key, cancel)
135
- #dialog.connect("key-release-event", _yn_key, cancel)
136
- warnings.simplefilter("default")
137
-
138
- dialog.show_all()
139
- response = dialog.run()
140
-
141
- # Convert all responses to cancel
142
- if response == Gtk.ResponseType.CANCEL or \
143
- response == Gtk.ResponseType.REJECT or \
144
- response == Gtk.ResponseType.CLOSE or \
145
- response == Gtk.ResponseType.DELETE_EVENT:
146
- response = Gtk.ResponseType.CANCEL
147
-
148
- dialog.destroy()
149
-
150
- #print("YNC result:", response);
151
- return response
152
-
153
- def _yn_key(win, event, cancel):
154
- #print event
155
- if event.keyval == Gdk.KEY_y or \
156
- event.keyval == Gdk.KEY_Y:
157
- win.response(Gtk.ResponseType.YES)
158
-
159
- if event.keyval == Gdk.KEY_n or \
160
- event.keyval == Gdk.KEY_N:
161
- win.response(Gtk.ResponseType.NO)
162
-
163
- if cancel:
164
- if event.keyval == Gdk.KEY_c or \
165
- event.keyval == Gdk.KEY_C:
166
- win.response(Gtk.ResponseType.CANCEL)
27
+ from gi.repository import GdkPixbuf
167
28
 
168
29
  # ------------------------------------------------------------------------
169
30
  # Resolve path name
@@ -180,12 +41,6 @@ def respath(fname):
180
41
  print ("Cannot resolve path", fname, sys.exc_info())
181
42
  return None
182
43
 
183
- # ------------------------------------------------------------------------
184
- # Random colors
185
-
186
- def randcol():
187
- return random.randint(0, 255)
188
-
189
44
  # ------------------------------------------------------------------------
190
45
  # Color conversions
191
46
 
@@ -249,7 +104,7 @@ def put_debug2(xstr):
249
104
  print( "Failed on debug output.")
250
105
  print( sys.exc_info())
251
106
 
252
- def put_exception_old(xstr):
107
+ def put_exception(xstr):
253
108
 
254
109
  cumm = xstr + " "
255
110
  a,b,c = sys.exc_info()
@@ -265,7 +120,7 @@ def put_exception_old(xstr):
265
120
  except:
266
121
  print( "Could not print trace stack. ", sys.exc_info())
267
122
 
268
- put_debug2(cumm)
123
+ print(cumm)
269
124
  #syslog.syslog("%s %s %s" % (xstr, a, b))
270
125
 
271
126
  def decode_bits(numx):
@@ -282,13 +137,6 @@ def decode_bits(numx):
282
137
 
283
138
  return retx
284
139
 
285
- def randcolstr(start = 0, endd = 255):
286
- rr = random.randint(start, endd)
287
- gg = random.randint(start, endd)
288
- bb = random.randint(start, endd)
289
- strx = "#%02x%02x%02x" % (rr, gg, bb)
290
- return strx
291
-
292
140
  # ------------------------------------------------------------------------
293
141
  # Remove non printables
294
142
 
@@ -386,39 +234,6 @@ def serial_ports():
386
234
  return result
387
235
  '''
388
236
 
389
- # ------------------------------------------------------------------------
390
- # Get random str
391
-
392
- def randstr(lenx):
393
-
394
- strx = ""
395
- for aa in range(lenx):
396
- ridx = random.randint(0, len(allstr)-1)
397
- rr = allstr[ridx]
398
- strx += str(rr)
399
-
400
- return strx
401
-
402
- def randasc(lenx):
403
-
404
- strx = ""
405
- for aa in range(lenx):
406
- ridx = random.randint(0, len(allasc)-1)
407
- rr = allasc[ridx]
408
- strx += str(rr)
409
-
410
- return strx
411
-
412
- def randlett(lenx):
413
-
414
- strx = ""
415
- for aa in range(lenx):
416
- ridx = random.randint(0, len(alllett)-1)
417
- rr = alllett[ridx]
418
- strx += str(rr)
419
-
420
- return strx
421
-
422
237
  # ------------------------------------------------------------------------
423
238
  # Convert octal string to integer
424
239
 
@@ -847,115 +662,39 @@ class Config:
847
662
  self.optarr[bb][3]()
848
663
  return args
849
664
 
850
- # ------------------------------------------------------------------------
851
-
852
- def yes_no_cancel(title, message, cancel = True):
853
-
854
- warnings.simplefilter("ignore")
855
-
856
- dialog = Gtk.Dialog(title,
857
- None,
858
- Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT)
859
-
860
- dialog.set_default_response(Gtk.ResponseType.YES)
861
- dialog.set_position(Gtk.WindowPosition.CENTER)
862
- #dialog.set_transient_for(pedconfig.conf.pedwin.mywin)
863
-
864
- sp = " "
865
- label = Gtk.Label(message)
866
- label2 = Gtk.Label(sp)
867
- label3 = Gtk.Label(sp)
868
- label2a = Gtk.Label(sp)
869
- label3a = Gtk.Label(sp)
870
-
871
- hbox = Gtk.HBox()
872
-
873
- hbox.pack_start(label2, 0, 0, 0)
874
- hbox.pack_start(label, 1, 1, 0)
875
- hbox.pack_start(label3, 0, 0, 0)
876
-
877
- dialog.vbox.pack_start(label2a, 0, 0, 0)
878
- dialog.vbox.pack_start(hbox, 0, 0, 0)
879
- dialog.vbox.pack_start(label3a, 0, 0, 0)
880
-
881
- dialog.add_button("_Yes", Gtk.ResponseType.YES)
882
- dialog.add_button("_No", Gtk.ResponseType.NO)
883
-
884
- if cancel:
885
- dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
886
-
887
- dialog.connect("key-press-event", _yn_key, cancel)
888
- #dialog.connect("key-release-event", _yn_key, cancel)
889
- warnings.simplefilter("default")
890
-
891
- dialog.show_all()
892
- response = dialog.run()
893
-
894
- # Convert all responses to cancel
895
- if response == Gtk.ResponseType.CANCEL or \
896
- response == Gtk.ResponseType.REJECT or \
897
- response == Gtk.ResponseType.CLOSE or \
898
- response == Gtk.ResponseType.DELETE_EVENT:
899
- response = Gtk.ResponseType.CANCEL
900
-
901
- dialog.destroy()
902
-
903
- #print("YNC result:", response);
904
- return response
905
-
906
- def _yn_key(win, event, cancel):
907
- #print event
908
- if event.keyval == Gdk.KEY_y or \
909
- event.keyval == Gdk.KEY_Y:
910
- win.response(Gtk.ResponseType.YES)
911
-
912
- if event.keyval == Gdk.KEY_n or \
913
- event.keyval == Gdk.KEY_N:
914
- win.response(Gtk.ResponseType.NO)
915
-
916
- if cancel:
917
- if event.keyval == Gdk.KEY_c or \
918
- event.keyval == Gdk.KEY_C:
919
- win.response(Gtk.ResponseType.CANCEL)
920
-
921
- def about2(self2):
665
+ def about(progname, verstr = "1.0.0", imgfile = "icon.png"):
922
666
 
923
667
  ''' Show About dialog: '''
924
668
 
925
669
  dialog = Gtk.AboutDialog()
926
- dialog.set_name(pedconfig.conf.progname + " - Python Editor ")
670
+ dialog.set_name(progname)
927
671
 
928
- dialog.set_version(str(pedconfig.conf.version))
672
+ dialog.set_version(verstr)
929
673
  gver = (Gtk.get_major_version(), \
930
674
  Gtk.get_minor_version(), \
931
675
  Gtk.get_micro_version())
932
676
 
933
677
  dialog.set_position(Gtk.WindowPosition.CENTER)
934
- dialog.set_transient_for(pedconfig.conf.pedwin.mywin)
678
+ #dialog.set_transient_for(pedconfig.conf.pedwin.mywin)
935
679
 
936
680
  #"\nRunning PyGObject %d.%d.%d" % GObject.pygobject_version +\
937
681
 
938
- ddd = os.path.join(os.path.dirname(__file__), "../")
682
+ ddd = os.path.join(os.path.dirname(__file__))
939
683
 
940
684
  # GLib.pyglib_version
941
685
  vvv = gi.version_info
942
- comm = "Python based easily configurable editor\n"\
943
- "with time accounting module, spell "\
944
- "check \n and macro recording.\n"\
945
- "\nRunning PyGtk %d.%d.%d" % vvv +\
946
- "\non GTK %d.%d.%d\n" % gver +\
686
+ comm = \
687
+ "Running PyGtk %d.%d.%d" % vvv +\
688
+ "\non GTK %d.%d.%d" % gver +\
947
689
  "\nRunning Python %s" % platform.python_version() +\
948
- "\non %s %s\n" % (platform.system(), platform.release()) +\
949
- "\nPyedPro Build Date: %s\n" % pedconfig.conf.build_date +\
950
- "Exe Path:\n%s\n" % os.path.realpath(ddd)
690
+ "\non %s %s" % (platform.system(), platform.release()) +\
691
+ "\nExe Path:\n%s" % os.path.realpath(ddd)
951
692
 
952
693
  dialog.set_comments(comm)
953
- dialog.set_copyright(pedconfig.conf.progname + " Created by Peter Glen.\n"
694
+ dialog.set_copyright(progname + " Created by Peter Glen.\n"
954
695
  "Project is in the Public Domain.")
955
- dialog.set_program_name(pedconfig.conf.progname)
956
- img_dir = os.path.join(os.path.dirname(__file__), 'images')
957
- #img_path = os.path.join(img_dir, 'gtk-logo-rgb.gif')
958
- img_path = os.path.join(img_dir, 'pyedpro.png')
696
+ dialog.set_program_name(progname)
697
+ img_path = os.path.join(os.path.dirname(__file__), imgfile)
959
698
 
960
699
  try:
961
700
  pixbuf = GdkPixbuf.Pixbuf.new_from_file(img_path)
@@ -970,11 +709,11 @@ def about2(self2):
970
709
 
971
710
  ## Close dialog on user response
972
711
  dialog.connect ("response", lambda d, r: d.destroy())
973
- dialog.connect("key-press-event", about_key)
712
+ dialog.connect("key-press-event", _about_key)
974
713
 
975
714
  dialog.show()
976
715
 
977
- def about_key(win, event):
716
+ def _about_key(win, event):
978
717
  #print "about_key", event
979
718
  if event.type == Gdk.EventType.KEY_PRESS:
980
719
  if event.keyval == Gdk.KEY_x or event.keyval == Gdk.KEY_X:
@@ -983,30 +722,25 @@ def about_key(win, event):
983
722
 
984
723
  # ------------------------------------------------------------------------
985
724
  # Show a regular message:
986
-
987
- def message3(strx, title = None):
988
-
989
- #print("called: message()", strx)
990
-
991
- icon = Gtk.STOCK_INFO
992
- dialog = Gtk.MessageDialog(buttons=Gtk.ButtonsType.CLOSE,
993
- message_type=Gtk.MessageType.INFO)
994
-
995
- dialog.props.text = strx
996
-
997
- #dialog.set_transient_for()
998
-
999
- if title:
1000
- dialog.set_title(title)
1001
- else:
1002
- dialog.set_title("PyEdPro")
1003
-
1004
- dialog.set_position(Gtk.WindowPosition.CENTER)
1005
-
1006
- # Close dialog on user response
1007
- dialog.connect("response", lambda d, r: d.destroy())
1008
- dialog.show()
1009
- dialog.run()
725
+ #
726
+ #def message3(strx, title = None):
727
+ #
728
+ # #print("called: message()", strx)
729
+ #
730
+ # icon = Gtk.STOCK_INFO
731
+ # dialog = Gtk.MessageDialog(buttons=Gtk.ButtonsType.CLOSE,
732
+ # message_type=Gtk.MessageType.INFO)
733
+ # dialog.props.text = strx
734
+ # #dialog.set_transient_for()
735
+ # if title:
736
+ # dialog.set_title(title)
737
+ # else:
738
+ # dialog.set_title("PyEdPro")
739
+ # dialog.set_position(Gtk.WindowPosition.CENTER)
740
+ # # Close dialog on user response
741
+ # dialog.connect("response", lambda d, r: d.destroy())
742
+ # dialog.show()
743
+ # dialog.run()
1010
744
 
1011
745
  # -----------------------------------------------------------------------
1012
746
  # Call func with all processes, func called with stat as its argument
@@ -1050,9 +784,9 @@ def find(self):
1050
784
  label5 = Gtk.Label(" "); label6 = Gtk.Label(" ")
1051
785
  label7 = Gtk.Label(" "); label8 = Gtk.Label(" ")
1052
786
 
1053
- warnings.simplefilter("ignore")
787
+ #warmings.simplefilter("ignore")
1054
788
  entry = Gtk.Entry()
1055
- warnings.simplefilter("default")
789
+ #warmings.simplefilter("default")
1056
790
  entry.set_text(self.oldfind)
1057
791
 
1058
792
  entry.set_activates_default(True)
@@ -1145,26 +879,6 @@ def print_exception(xstr):
1145
879
  print("Could not print trace stack. ", sys.exc_info())
1146
880
  print( cumm)
1147
881
 
1148
-
1149
- # ------------------------------------------------------------------------
1150
- # Show a regular message:
1151
-
1152
- def message(strx, parent = None, title = None, icon = Gtk.MessageType.INFO):
1153
-
1154
- dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
1155
- icon, Gtk.ButtonsType.CLOSE, strx)
1156
-
1157
- dialog.set_modal(True)
1158
-
1159
- if title:
1160
- dialog.set_title(title)
1161
- else:
1162
- dialog.set_title("DBGui Message")
1163
-
1164
- # Close dialog on user response
1165
- dialog.connect("response", lambda d, r: d.destroy())
1166
- dialog.show()
1167
-
1168
882
  # -----------------------------------------------------------------------
1169
883
  # Sleep just a little, but allow the system to breed
1170
884
 
@@ -1246,72 +960,6 @@ def time_s2n(sss):
1246
960
  ttt = time.mktime(rrr)
1247
961
  return ttt
1248
962
 
1249
- def yes_no_cancel(title, message, cancel = True, parent = None):
1250
-
1251
- #warnings.simplefilter("ignore")
1252
- dialog = Gtk.Dialog(title,
1253
- None,
1254
- Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT)
1255
-
1256
-
1257
- dialog.set_default_response(Gtk.ResponseType.YES)
1258
- dialog.set_position(Gtk.WindowPosition.CENTER)
1259
- dialog.set_transient_for(parent)
1260
-
1261
- sp = " "
1262
- label = Gtk.Label(message)
1263
- label2 = Gtk.Label(sp)
1264
- label3 = Gtk.Label(sp)
1265
- label2a = Gtk.Label(sp)
1266
- label3a = Gtk.Label(sp)
1267
-
1268
- hbox = Gtk.HBox()
1269
-
1270
- hbox.pack_start(label2, 0, 0, 0)
1271
- hbox.pack_start(label, 1, 1, 0)
1272
- hbox.pack_start(label3, 0, 0, 0)
1273
-
1274
- dialog.vbox.pack_start(label2a, 0, 0, 0)
1275
- dialog.vbox.pack_start(hbox, 0, 0, 0)
1276
- dialog.vbox.pack_start(label3a, 0, 0, 0)
1277
-
1278
- dialog.add_button("_Yes", Gtk.ResponseType.YES)
1279
- dialog.add_button("_No", Gtk.ResponseType.NO)
1280
-
1281
- if cancel:
1282
- dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
1283
-
1284
- dialog.connect("key-press-event", yn_key, cancel)
1285
- #dialog.connect("key-release-event", yn_key, cancel)
1286
- #warnings.simplefilter("default")
1287
-
1288
- dialog.show_all()
1289
- response = dialog.run()
1290
- # Convert all responses to cancel
1291
- if response == Gtk.ResponseType.CANCEL or \
1292
- response == Gtk.ResponseType.REJECT or \
1293
- response == Gtk.ResponseType.CLOSE or \
1294
- response == Gtk.ResponseType.DELETE_EVENT:
1295
- response = Gtk.ResponseType.CANCEL
1296
- dialog.destroy()
1297
-
1298
- return response
1299
-
1300
- def yn_key(win, event, cancel):
1301
- #print( event)
1302
- if event.keyval == Gdk.KEY_y or \
1303
- event.keyval == Gdk.KEY_Y:
1304
- win.response(Gtk.ResponseType.YES)
1305
-
1306
- if event.keyval == Gdk.KEY_n or \
1307
- event.keyval == Gdk.KEY_N:
1308
- win.response(Gtk.ResponseType.NO)
1309
-
1310
- if cancel:
1311
- if event.keyval == Gdk.KEY_c or \
1312
- event.keyval == Gdk.KEY_C:
1313
- win.response(Gtk.ResponseType.CANCEL)
1314
-
1315
963
  def opendialog(parent=None):
1316
964
 
1317
965
  # We create an array, so it is passed around by reference