gtk-stream 0.1__py3-none-any.whl → 0.2.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.
gtk_stream/common.py CHANGED
@@ -1,10 +1,19 @@
1
1
  import sys
2
2
 
3
- def printEvent(event, id):
4
- def ret(w):
3
+ def _data_str_default(*args):
4
+ return ''
5
+ def _data_str_by(get_data):
6
+ def ret(*args):
7
+ return ":"+get_data(*args)
8
+ return ret
9
+
10
+ def printEvent(event, id, retval = None, get_data = None):
11
+ data_str = _data_str_default if get_data == None else _data_str_by(get_data)
12
+ def ret(*args):
5
13
  try:
6
- print(f"{id}:{event}", file=sys.stdout)
14
+ print("{}:{}{}".format(id,event,data_str(*args)), file=sys.stdout)
7
15
  sys.stdout.flush()
8
- except:
9
- print("Broken pipe, right ?", file=sys.stderr)
16
+ except Exception as e:
17
+ print("Exception when writing an event: {}".format(e))
18
+ return retval
10
19
  return ret
@@ -1,9 +1,10 @@
1
1
  from .classes.Document import Document
2
2
 
3
3
  from .classes.Label import Label
4
- from .classes.Button import Button
4
+ from .classes.Button import Button, LinkButton
5
5
  from .classes.ProgressBar import ProgressBar
6
6
  from .classes.Dropdown import Dropdown, Item
7
+ from .classes.Switch import Switch
7
8
 
8
9
  from .classes.Box import Box
9
10
  from .classes.Paned import Paned
@@ -11,3 +11,13 @@ class Button(Document):
11
11
  return button
12
12
  def attach_child(self, w, d):
13
13
  w.set_child(d.render())
14
+
15
+ class LinkButton(Button):
16
+ def __init__(self, app, id, **kwargs):
17
+ super().__init__(app, id=id, **kwargs)
18
+ def render_raw(self):
19
+ button = Gtk.LinkButton()
20
+ button.connect('activate-link', printEvent('clicked', self.id, True))
21
+ return button
22
+ def attach_child(self, w, d):
23
+ w.set_child(d.render())
@@ -1,5 +1,6 @@
1
1
  from ... import Gtk, Gio, GObject
2
2
  from .. import Document
3
+ from ...common import printEvent
3
4
 
4
5
  class Item(Document):
5
6
  def __init__(self, app, value, **kwargs):
@@ -41,10 +42,7 @@ class Dropdown(Document):
41
42
 
42
43
  ret = Gtk.DropDown(model=model, expression=Gtk.PropertyExpression.new(_ItemObject, None, 'item_value'), factory=factory)
43
44
 
44
- def on_selection_change(w,d):
45
- print(f"{self.id}:selected:{w.get_selected_item().value}")
46
- sys.stdout.flush()
47
- ret.connect('notify::selected-item', on_selection_change)
45
+ ret.connect('notify::selected-item', printEvent('selected', self.id, get_data = lambda w,_: w.get_selected_item().value))
48
46
  return ret
49
47
  def attach_child(self, w, d):
50
48
  pass
@@ -0,0 +1,15 @@
1
+ from ... import Gtk
2
+ from ...common import printEvent
3
+ from .. import Document
4
+ from ...properties import parse_property
5
+
6
+ class Switch(Document):
7
+ def __init__(self, app, id, managed = "false", **kwargs):
8
+ super().__init__(app, id=id, **kwargs)
9
+ self.managed = parse_property('managed', managed)
10
+ def render_raw(self):
11
+ ret = Gtk.Switch()
12
+ ret.connect('state-set', printEvent('switch', self.id,
13
+ retval = self.managed,
14
+ get_data = lambda _,state: "on" if state else "off"))
15
+ return ret
gtk_stream/parser.py CHANGED
@@ -3,7 +3,7 @@ import signal
3
3
  import xml.sax as sax
4
4
 
5
5
  from . import GLib
6
- from .documents import Document, Label, Box, Button, ProgressBar, Dropdown, Item, Paned, Frame, Grid, Cell
6
+ from .documents import Document, Label, Box, Button, ProgressBar, Dropdown, Item, Paned, Frame, Grid, Cell, LinkButton, Switch
7
7
  from .application import GtkStreamApp
8
8
 
9
9
  class _Object:
@@ -19,7 +19,9 @@ WIDGET_DOCUMENTS = {
19
19
  'paned': Paned,
20
20
  'grid': Grid,
21
21
  'cell': Cell,
22
- 'frame': Frame
22
+ 'frame': Frame,
23
+ 'link': LinkButton,
24
+ 'switch': Switch
23
25
  }
24
26
 
25
27
  class GtkStreamXMLHandler(sax.ContentHandler):
gtk_stream/properties.py CHANGED
@@ -26,12 +26,15 @@ _PARSE_PROPERTY = {
26
26
  'show-text': _parse_boolean_property,
27
27
  'enable-search': _parse_boolean_property,
28
28
  'search-match-mode': _parse_searchMode_property,
29
+ 'visited': _parse_boolean_property,
29
30
  'hexpand': _parse_boolean_property,
30
31
  'hexpand-set': _parse_boolean_property,
31
32
  'vexpand': _parse_boolean_property,
32
33
  'vexpand-set': _parse_boolean_property,
33
34
  'xalign': _parse_float_property,
34
- 'yalign': _parse_float_property
35
+ 'yalign': _parse_float_property,
36
+ 'state': _parse_boolean_property,
37
+ 'managed': _parse_boolean_property
35
38
  }
36
39
 
37
40
  def parse_property(prop, val):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gtk-stream
3
- Version: 0.1
3
+ Version: 0.2.1
4
4
  Summary: A simple stream-oriented GUI protocol
5
5
  Author-email: Marc Coiffier <marc.coiffier@univ-grenoble-alpes.fr>
6
6
  Project-URL: Homepage, https://coiffiem.gricad-pages.univ-grenoble-alpes.fr/gtk-stream/
@@ -0,0 +1,23 @@
1
+ gtk_stream/__init__.py,sha256=pDhUSN4AYNsP8_tilU1zmDCYdiv7ak4PE1TW0qFrDlg,99
2
+ gtk_stream/application.py,sha256=FZe4gQm5U0NGKKpi_Pp7VqxMtlbdbNJOYhcradzeSH4,3068
3
+ gtk_stream/command_line.py,sha256=c2ghqIQB5hYxtCszss1z84yKoeRYvaMJJMi4aiTspWg,312
4
+ gtk_stream/common.py,sha256=w_ez6-2PtWvvd51T8D8KUHbfEdkPfQMN9ll0jqWC6YM,573
5
+ gtk_stream/parser.py,sha256=ZyCm1WKgKH6syqyUCY7ZyTW642LMpzQ_dDSNsvcNsLY,6797
6
+ gtk_stream/properties.py,sha256=9bYzvqmUq8EidtBDZdKupLgYM9ucIGyxmahcIp9TxT8,1542
7
+ gtk_stream/documents/__init__.py,sha256=vTgKiiafqqkSOIUwOIzO40VsSdCpHFnGOGRm8rRv9mY,378
8
+ gtk_stream/documents/classes/Box.py,sha256=6l9Z3GpC0Yv34jcGNTwlNLM5DpYyQ1iDihJsu1nxcy8,259
9
+ gtk_stream/documents/classes/Button.py,sha256=_NjoOrgdSVK4RQbh0V-QiZ_hfHasaMc9LQ2bf2egbe4,747
10
+ gtk_stream/documents/classes/Document.py,sha256=scoJrdHen_1WRuqn3aN6FJUesHXPZZyKwmPuPDjjbzI,985
11
+ gtk_stream/documents/classes/Dropdown.py,sha256=0Y9Sua_0Y_1F6bq4SQe1IDdJThhh5KVpepAExcPo8bg,1675
12
+ gtk_stream/documents/classes/Frame.py,sha256=p8OcgYBki1NWe2tveZfRwb0aQzRAeHQa9wHmpjgRJoc,391
13
+ gtk_stream/documents/classes/Grid.py,sha256=SRDbMhPZHV372KN7Qr9vvamH2xwr39eojeWmI0Rf8hE,622
14
+ gtk_stream/documents/classes/Label.py,sha256=BeL3zlf9YPuBGYS_YtHI0Q-MoVVLPao7kPIzPlwpyHY,275
15
+ gtk_stream/documents/classes/Paned.py,sha256=4jZGEebhv9pNzTyYbQ8lyx_nsKd9Nmr10703V5n_kNw,644
16
+ gtk_stream/documents/classes/ProgressBar.py,sha256=2_KCboyweGsqpBck61TvVGZYIsN8QVzAyqwwTDh-pDU,212
17
+ gtk_stream/documents/classes/Switch.py,sha256=uXmd_cZPZXkM31wYE4Z5d1-wuxqdt7wvS6qoE8ubaGc,610
18
+ gtk_stream/documents/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ gtk_stream-0.2.1.dist-info/METADATA,sha256=jgZJztL7DBRF09_DgxwNS89E4ImlddOxX3DNj0dyF_I,506
20
+ gtk_stream-0.2.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
21
+ gtk_stream-0.2.1.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
22
+ gtk_stream-0.2.1.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
23
+ gtk_stream-0.2.1.dist-info/RECORD,,
@@ -1,22 +0,0 @@
1
- gtk_stream/__init__.py,sha256=pDhUSN4AYNsP8_tilU1zmDCYdiv7ak4PE1TW0qFrDlg,99
2
- gtk_stream/application.py,sha256=FZe4gQm5U0NGKKpi_Pp7VqxMtlbdbNJOYhcradzeSH4,3068
3
- gtk_stream/command_line.py,sha256=c2ghqIQB5hYxtCszss1z84yKoeRYvaMJJMi4aiTspWg,312
4
- gtk_stream/common.py,sha256=6v6vIFzi1mZvATUzSIb9hPKLcdCexjfBJJm2vafD8Ps,241
5
- gtk_stream/parser.py,sha256=GHq08hKSEVBphtnGm4G_evfE2PeB0QLzp5PDM6fR890,6731
6
- gtk_stream/properties.py,sha256=e6A2tjNjTVIGbNNQE8rOQUwB1uP9AZvIJl3MzdhbPIg,1392
7
- gtk_stream/documents/__init__.py,sha256=JArZ2Ry5u4Y9hyzdoBG_W47PgqZ-Og1UdWDdUVjhlW0,331
8
- gtk_stream/documents/classes/Box.py,sha256=6l9Z3GpC0Yv34jcGNTwlNLM5DpYyQ1iDihJsu1nxcy8,259
9
- gtk_stream/documents/classes/Button.py,sha256=CYTKNl0OR-xPB9VWvyXtnAtZWuQQ9CxrtxoqjxiwgMM,404
10
- gtk_stream/documents/classes/Document.py,sha256=scoJrdHen_1WRuqn3aN6FJUesHXPZZyKwmPuPDjjbzI,985
11
- gtk_stream/documents/classes/Dropdown.py,sha256=uDH1yfYoEGugen6O62EMf7Dh9WfqFjUj_fgxFZ395VY,1718
12
- gtk_stream/documents/classes/Frame.py,sha256=p8OcgYBki1NWe2tveZfRwb0aQzRAeHQa9wHmpjgRJoc,391
13
- gtk_stream/documents/classes/Grid.py,sha256=SRDbMhPZHV372KN7Qr9vvamH2xwr39eojeWmI0Rf8hE,622
14
- gtk_stream/documents/classes/Label.py,sha256=BeL3zlf9YPuBGYS_YtHI0Q-MoVVLPao7kPIzPlwpyHY,275
15
- gtk_stream/documents/classes/Paned.py,sha256=4jZGEebhv9pNzTyYbQ8lyx_nsKd9Nmr10703V5n_kNw,644
16
- gtk_stream/documents/classes/ProgressBar.py,sha256=2_KCboyweGsqpBck61TvVGZYIsN8QVzAyqwwTDh-pDU,212
17
- gtk_stream/documents/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- gtk_stream-0.1.dist-info/METADATA,sha256=Hq2t55xlbQkAi4hXM9-0sykB31YXCN16TQq1aztu4tI,504
19
- gtk_stream-0.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
20
- gtk_stream-0.1.dist-info/entry_points.txt,sha256=PmhKTb4MMQM6dN2HJcoDSMI8L0lZIFIlFn-BgdfPDpo,60
21
- gtk_stream-0.1.dist-info/top_level.txt,sha256=vE9zfHGe9Ke7FSe0wBK2WYJI-BpcQNu6xDC3Cu5O8rQ,11
22
- gtk_stream-0.1.dist-info/RECORD,,