pyvguicom 1.0.0__py3-none-any.whl → 1.0.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/sutil.py DELETED
@@ -1,344 +0,0 @@
1
- #!/usr/bin/python3
2
-
3
- from __future__ import absolute_import
4
- from __future__ import print_function
5
-
6
- import sys, traceback, os, time, warnings
7
-
8
- import gi
9
- gi.require_version("Gtk", "3.0")
10
- from gi.repository import Gtk
11
- from gi.repository import Gdk
12
- from gi.repository import GObject
13
- from gi.repository import GLib
14
-
15
- disp = Gdk.Display.get_default()
16
- scr = disp.get_default_screen()
17
-
18
- #print( "num_mon", scr.get_n_monitors() )
19
- #for aa in range(scr.get_n_monitors()):
20
- # print( "mon", aa, scr.get_monitor_geometry(aa);)
21
-
22
- # ------------------------------------------------------------------------
23
- # Get current screen (monitor) width and height
24
-
25
- def get_screen_wh():
26
-
27
- ptr = disp.get_pointer()
28
- mon = scr.get_monitor_at_point(ptr[1], ptr[2])
29
- geo = scr.get_monitor_geometry(mon)
30
- www = geo.width; hhh = geo.height
31
- if www == 0 or hhh == 0:
32
- www = Gdk.get_screen_width();
33
- hhh = Gdk.get_screen_height();
34
- return www, hhh
35
-
36
- # ------------------------------------------------------------------------
37
- # Get current screen (monitor) upper left corner xx / yy
38
-
39
- def get_screen_xy():
40
-
41
- ptr = disp.get_pointer()
42
- mon = scr.get_monitor_at_point(ptr[1], ptr[2])
43
- geo = scr.get_monitor_geometry(mon)
44
- return geo.x, geo.y
45
-
46
- # ------------------------------------------------------------------------
47
- # Print( an exception as the system would print it)
48
-
49
- def print_exception(xstr):
50
- cumm = xstr + " "
51
- a,b,c = sys.exc_info()
52
- if a != None:
53
- cumm += str(a) + " " + str(b) + "\n"
54
- try:
55
- #cumm += str(traceback.format_tb(c, 10))
56
- ttt = traceback.extract_tb(c)
57
- for aa in ttt:
58
- cumm += "File: " + os.path.basename(aa[0]) + \
59
- " Line: " + str(aa[1]) + "\n" + \
60
- " Context: " + aa[2] + " -> " + aa[3] + "\n"
61
- except:
62
- print("Could not print trace stack. ", sys.exc_info())
63
- print( cumm)
64
-
65
-
66
- # ------------------------------------------------------------------------
67
- # Show a regular message:
68
-
69
- def message(strx, parent = None, title = None, icon = Gtk.MessageType.INFO):
70
-
71
- dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
72
- icon, Gtk.ButtonsType.CLOSE, strx)
73
-
74
- dialog.set_modal(True)
75
-
76
- if title:
77
- dialog.set_title(title)
78
- else:
79
- dialog.set_title("DBGui Message")
80
-
81
- # Close dialog on user response
82
- dialog.connect("response", lambda d, r: d.destroy())
83
- dialog.show()
84
-
85
-
86
- # -----------------------------------------------------------------------
87
- # Sleep just a little, but allow the system to breed
88
-
89
- def usleep(msec):
90
-
91
- if sys.version_info[0] < 3 or \
92
- (sys.version_info[0] == 3 and sys.version_info[1] < 3):
93
- timefunc = time.clock
94
- else:
95
- timefunc = time.process_time
96
-
97
- got_clock = timefunc() + float(msec) / 1000
98
- #print( got_clock)
99
- while True:
100
- if timefunc() > got_clock:
101
- break
102
- #print ("Sleeping")
103
- Gtk.main_iteration_do(False)
104
-
105
- # ------------------------------------------------------------------------
106
- # Create temporary file, return name. Empty string ("") if error.
107
-
108
- def tmpname(indir, template):
109
-
110
- fname = ""
111
- if not os.access(indir, os.W_OK):
112
- print( "Cannot access ", indir)
113
- return fname
114
-
115
- cnt = 1;
116
- while True:
117
- tmp = indir + "/" + template + "_" + str(cnt)
118
- if not os.access(tmp, os.R_OK):
119
- fname = tmp
120
- break
121
- # Safety valve
122
- if cnt > 10000:
123
- break
124
- return fname
125
-
126
- # ------------------------------------------------------------------------
127
- # Execute man loop
128
-
129
- def mainloop():
130
- while True:
131
- ev = Gdk.event_peek()
132
- #print( ev)
133
- if ev:
134
- if ev.type == Gdk.EventType.DELETE:
135
- break
136
- if ev.type == Gdk.EventType.UNMAP:
137
- break
138
- if Gtk.main_iteration_do(True):
139
- break
140
-
141
- class Unbuffered(object):
142
- def __init__(self, stream):
143
- self.stream = stream
144
-
145
- def write(self, data):
146
- self.stream.write(data)
147
- self.stream.flush()
148
-
149
- def writelines(self, datas):
150
- self.stream.writelines(datas)
151
- self.stream.flush()
152
-
153
- def __getattr__(self, attr):
154
- return getattr(self.stream, attr)
155
-
156
- # Time to str and str to time
157
-
158
- def time_n2s(ttt):
159
- sss = time.ctime(ttt)
160
- return sss
161
-
162
- def time_s2n(sss):
163
- rrr = time.strptime(sss)
164
- ttt = time.mktime(rrr)
165
- return ttt
166
-
167
- def yes_no_cancel(title, message, cancel = True, parent = None):
168
-
169
- #warnings.simplefilter("ignore")
170
- dialog = Gtk.Dialog(title,
171
- None,
172
- Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT)
173
-
174
-
175
- dialog.set_default_response(Gtk.ResponseType.YES)
176
- dialog.set_position(Gtk.WindowPosition.CENTER)
177
- dialog.set_transient_for(parent)
178
-
179
- sp = " "
180
- label = Gtk.Label(message);
181
- label2 = Gtk.Label(sp); label3 = Gtk.Label(sp)
182
- label2a = Gtk.Label(sp); label3a = Gtk.Label(sp)
183
-
184
- hbox = Gtk.HBox() ;
185
-
186
- hbox.pack_start(label2, 0, 0, 0);
187
- hbox.pack_start(label, 1, 1, 0);
188
- hbox.pack_start(label3, 0, 0, 0)
189
-
190
- dialog.vbox.pack_start(label2a, 0, 0, 0);
191
- dialog.vbox.pack_start(hbox, 0, 0, 0)
192
- dialog.vbox.pack_start(label3a, 0, 0, 0);
193
-
194
- dialog.add_button("_Yes", Gtk.ResponseType.YES)
195
- dialog.add_button("_No", Gtk.ResponseType.NO)
196
-
197
- if cancel:
198
- dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
199
-
200
- dialog.connect("key-press-event", yn_key, cancel)
201
- #dialog.connect("key-release-event", yn_key, cancel)
202
- #warnings.simplefilter("default")
203
-
204
- dialog.show_all()
205
- response = dialog.run()
206
- # Convert all responses to cancel
207
- if response == Gtk.ResponseType.CANCEL or \
208
- response == Gtk.ResponseType.REJECT or \
209
- response == Gtk.ResponseType.CLOSE or \
210
- response == Gtk.ResponseType.DELETE_EVENT:
211
- response = Gtk.ResponseType.CANCEL
212
- dialog.destroy()
213
-
214
- return response
215
-
216
- def yn_key(win, event, cancel):
217
- #print( event)
218
- if event.keyval == Gdk.KEY_y or \
219
- event.keyval == Gdk.KEY_Y:
220
- win.response(Gtk.ResponseType.YES)
221
-
222
- if event.keyval == Gdk.KEY_n or \
223
- event.keyval == Gdk.KEY_N:
224
- win.response(Gtk.ResponseType.NO)
225
-
226
- if cancel:
227
- if event.keyval == Gdk.KEY_c or \
228
- event.keyval == Gdk.KEY_C:
229
- win.response(Gtk.ResponseType.CANCEL)
230
-
231
- def opendialog(parent=None):
232
-
233
- # We create an array, so it is passed around by reference
234
- fname = [""]
235
-
236
- def makefilter(mask, name):
237
- filter = Gtk.FileFilter.new()
238
- filter.add_pattern(mask)
239
- filter.set_name(name)
240
- return filter
241
-
242
- def done_open_fc(win, resp, fname):
243
- #print "done_open_fc", win, resp
244
- if resp == Gtk.ButtonsType.OK:
245
- fname[0] = win.get_filename()
246
- if not fname[0]:
247
- #print "Must have filename"
248
- pass
249
- elif os.path.isdir(fname[0]):
250
- os.chdir(fname[0])
251
- win.set_current_folder(fname[0])
252
- return
253
- else:
254
- #print("OFD", fname[0])
255
- pass
256
- win.destroy()
257
-
258
- but = "Cancel", Gtk.ButtonsType.CANCEL,\
259
- "Open File", Gtk.ButtonsType.OK
260
-
261
- fc = Gtk.FileChooserDialog("Open file", parent, \
262
- Gtk.FileChooserAction.OPEN \
263
- , but)
264
-
265
- filters = []
266
- filters.append(makefilter("*.mup", "MarkUp files (*.py)"))
267
- filters.append(makefilter("*.*", "All files (*.*)"))
268
-
269
- if filters:
270
- for aa in filters:
271
- fc.add_filter(aa)
272
-
273
- fc.set_default_response(Gtk.ButtonsType.OK)
274
- fc.set_current_folder(os.getcwd())
275
- fc.connect("response", done_open_fc, fname)
276
- #fc.connect("current-folder-changed", self.folder_ch )
277
- #fc.set_current_name(self.fname)
278
- fc.run()
279
- #print("OFD2", fname[0])
280
- return fname[0]
281
-
282
- def savedialog(resp):
283
-
284
- #print "File dialog"
285
- fname = [""] # So it is passed around as a reference
286
-
287
- def makefilter(mask, name):
288
- filter = Gtk.FileFilter.new()
289
- filter.add_pattern(mask)
290
- filter.set_name(name)
291
- return filter
292
-
293
- def done_fc(win, resp, fname):
294
- #print( "done_fc", win, resp)
295
- if resp == Gtk.ResponseType.OK:
296
- fname[0] = win.get_filename()
297
- if not fname[0]:
298
- print("Must have filename")
299
- else:
300
- pass
301
- win.destroy()
302
-
303
- but = "Cancel", Gtk.ResponseType.CANCEL, \
304
- "Save File", Gtk.ResponseType.OK
305
- fc = Gtk.FileChooserDialog("Save file as ... ", None,
306
- Gtk.FileChooserAction.SAVE, but)
307
-
308
- #fc.set_do_overwrite_confirmation(True)
309
-
310
- filters = []
311
- filters.append(makefilter("*.mup", "MarkUp files (*.py)"))
312
- filters.append(makefilter("*.*", "All files (*.*)"))
313
-
314
- if filters:
315
- for aa in filters:
316
- fc.add_filter(aa)
317
-
318
- fc.set_current_name(os.path.basename(fname[0]))
319
- fc.set_current_folder(os.path.dirname(fname[0]))
320
- fc.set_default_response(Gtk.ResponseType.OK)
321
- fc.connect("response", done_fc, fname)
322
- fc.run()
323
- return fname[0]
324
-
325
- # ------------------------------------------------------------------------
326
- # Count lead spaces
327
-
328
- def leadspace(strx):
329
- cnt = 0;
330
- for aa in range(len(strx)):
331
- bb = strx[aa]
332
- if bb == " ":
333
- cnt += 1
334
- elif bb == "\t":
335
- cnt += 1
336
- elif bb == "\r":
337
- cnt += 1
338
- elif bb == "\n":
339
- cnt += 1
340
- else:
341
- break
342
- return cnt
343
-
344
- # EOF
@@ -1,23 +0,0 @@
1
- pyvguicom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- pyvguicom/browsewin.py,sha256=ylzec-uvankcsA_2LqlEVcl0C8FjDvXA2KY-0AQBrFw,7530
3
- pyvguicom/htmledit.py,sha256=gSxabFFGFxgaNvYtWOsXaaHCzYB-r6i7J5dhVLriQ94,10064
4
- pyvguicom/pgbox.py,sha256=ADxGXFq_lZZy-tRjes1bJVwz9TLzcglc1I1ib3kWLEQ,21912
5
- pyvguicom/pgbutt.py,sha256=f-0YeSu3axX-Cojdt9mR6o0odWKYhjt06NhltpHfEv0,6700
6
- pyvguicom/pgentry.py,sha256=a4jy-0G5OEZw6JHJUeS0x-r04xlbxZOsmF7NDRSkKvY,4932
7
- pyvguicom/pggui.py,sha256=RxbhFVJE9lFNEr9T_aEu653IU620y6RtXISjb8ERGm8,40484
8
- pyvguicom/pgsimp.py,sha256=muwfeUqEDZFsvM2c2FT3xkBLtpGufCvCKK__Dixe-7k,15446
9
- pyvguicom/pgtextview.py,sha256=mzCxTmRAJTVzxYRAzDTOnyS9TRQlcwSHpDqes-PJblc,29354
10
- pyvguicom/pgutils.py,sha256=1wLkRizgJtnCu2YgpYaxByveaXrov_RwuxOkwt8DANI,31741
11
- pyvguicom/pgwkit.py,sha256=4xpEzZtPiimDcR1Zer4Sej9u08L0JrgfV9g67rnwyZQ,25820
12
- pyvguicom/plug.py,sha256=qyoJtpEWCBwyp5DG9fwzrcJL-SqTjL9KzZ418YSaPwc,1017
13
- pyvguicom/sutil.py,sha256=vHkJYlXDk-irZefFmdk3Q-tsmoWvGE0X-12PH5IpDtA,9570
14
- pyvguicom/testbutt.py,sha256=N9rM3xhCd5nsShi7tSN-yjIj7PJMrNVWydCyJoKrcAU,2800
15
- pyvguicom/testicons.py,sha256=5Wd7Rk3vIyv61K4tvwCDVh_NclVrvf30ALsvfEhyQnQ,8947
16
- pyvguicom/testnums.py,sha256=0H3tCFzYm74v7iKRlXfoDoWcxA7oVspsJGvySKPo14U,3222
17
- pyvguicom/testroot.py,sha256=NKoDYFgzNW5lZzOIzN0h-rP_XcccUVqa_OdSrR7fx5I,4058
18
- pyvguicom/testsimple.py,sha256=jILucudbGUxVAKZuUaACOUKKWTTlBSm4RlUcc0HJHLk,2401
19
- pyvguicom/testtextv.py,sha256=j2HxT3HWML2VI6esEFFsRXMh1JozIlQiNWrsrdo-4FE,7193
20
- pyvguicom-1.0.0.dist-info/METADATA,sha256=iCVyieKbikIWNuOeD9MjvB72NJIj0dXtXEpDp-6SVoA,2792
21
- pyvguicom-1.0.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
22
- pyvguicom-1.0.0.dist-info/top_level.txt,sha256=TWIDRa6pMhB1Y4N_lGT1aO6tLoV7ZSUMlj0IaAHjm38,10
23
- pyvguicom-1.0.0.dist-info/RECORD,,