4747 pass
4848
4949# This is the main class
50- class Combi_DRO (Gtk .VBox ):
50+ class Combi_DRO (Gtk .Box ):
5151 '''
5252 Combi_DRO will display an linuxcnc DRO with all three types at ones
5353
@@ -104,6 +104,7 @@ class Combi_DRO(Gtk.VBox):
104104 # Init the class
105105 def __init__ (self , joint_number = 0 ):
106106 super (Combi_DRO , self ).__init__ ()
107+ self .set_orientation (Gtk .Orientation .VERTICAL )
107108
108109 # we have to distinguish this, as we use the joints number to check homing
109110 # and we do need the axis to check for the positions
@@ -142,7 +143,7 @@ def __init__(self, joint_number = 0):
142143 self .widgets = {} # will hold all our widgets we need to style
143144
144145 # Make the GUI and connect signals
145-
146+
146147 self .css_text = """
147148 .background {background-color: #000000;}
148149 .labelcolor {color: #FF0000;}
@@ -157,9 +158,10 @@ def __init__(self, joint_number = 0):
157158 eventbox .get_style_context ().add_provider (self .css ,Gtk .STYLE_PROVIDER_PRIORITY_APPLICATION )
158159 eventbox .get_style_context ().add_class ('background' )
159160 self .add (eventbox )
160- vbox_main = Gtk .VBox (homogeneous = False , spacing = 0 )
161+ vbox_main = Gtk .Box (homogeneous = False , spacing = 0 )
162+ vbox_main .set_orientation (Gtk .Orientation .VERTICAL )
161163 eventbox .add (vbox_main )
162- hbox_up = Gtk .HBox (homogeneous = False , spacing = 5 )
164+ hbox_up = Gtk .Box (homogeneous = False , spacing = 5 )
163165 vbox_main .pack_start (hbox_up , True , True , 0 )
164166 self .widgets ["eventbox" ] = eventbox
165167
@@ -171,12 +173,13 @@ def __init__(self, joint_number = 0):
171173 hbox_up .pack_start (lbl_axisletter , False , False , 0 )
172174 self .widgets ["lbl_axisletter" ] = lbl_axisletter
173175
174- vbox_ref_type = Gtk .VBox (homogeneous = False , spacing = 0 )
176+ vbox_ref_type = Gtk .Box (homogeneous = False , spacing = 0 )
177+ vbox_ref_type .set_orientation (Gtk .Orientation .VERTICAL )
175178 hbox_up .pack_start (vbox_ref_type , False , False , 0 )
176179 # This label is needed to press the main index (rel,Abs;Dtg) to the upper part
177180 lbl_space = Gtk .Label (label = "" )
178181 vbox_ref_type .pack_start (lbl_space , True , True , 0 )
179-
182+
180183 lbl_sys_main = Gtk .Label (label = self .system )
181184 lbl_sys_main .get_style_context ().add_provider (self .css ,Gtk .STYLE_PROVIDER_PRIORITY_APPLICATION )
182185 lbl_sys_main .get_style_context ().add_class ('background' )
@@ -194,7 +197,7 @@ def __init__(self, joint_number = 0):
194197 hbox_up .pack_start (main_dro , True , True , 0 )
195198 self .widgets ["main_dro" ] = main_dro
196199
197- hbox_down = Gtk .HBox (homogeneous = True , spacing = 5 )
200+ hbox_down = Gtk .Box (homogeneous = True , spacing = 5 )
198201 vbox_main .pack_start (hbox_down , False , False , 0 )
199202
200203 lbl_sys_left = Gtk .Label (label = "Abs" )
@@ -223,7 +226,7 @@ def __init__(self, joint_number = 0):
223226 lbl_sys_right .get_style_context ().add_class ('size_small' )
224227 hbox_down .pack_start (lbl_sys_right , False , False , 0 )
225228 self .widgets ["lbl_sys_right" ] = lbl_sys_right
226-
229+
227230 dro_right = Gtk .Label (label = "22.222" )
228231 dro_right .get_style_context ().add_provider (self .css ,Gtk .STYLE_PROVIDER_PRIORITY_APPLICATION )
229232 dro_right .get_style_context ().add_class ('background' )
@@ -278,6 +281,7 @@ def _on_eventbox_clicked(self, widget, event):
278281 def do_get_property (self , property ):
279282 name = property .name .replace ('-' , '_' )
280283 if name in list (self .__gproperties .keys ()):
284+ if name == 'auto_units' : name = '_auto_units'
281285 return getattr (self , name )
282286 else :
283287 raise AttributeError ('unknown property %s' % property .name )
@@ -362,7 +366,10 @@ def _get_current_units(self):
362366
363367 # update the labels
364368 def _set_labels (self ):
365- self .status .poll ()
369+ try :
370+ self .status .poll ()
371+ except :
372+ pass
366373 if self ._ORDER [0 ] == "Rel" :
367374 self .widgets ["lbl_sys_main" ].set_text (self ._get_current_system ())
368375 else :
@@ -389,38 +396,38 @@ def set_style(self, property, Data):
389396 if property == "background" :
390397 for widget in self .widgets :
391398 self .widgets [widget ].get_style_context ().remove_class ('background' )
392- replacement_string = ".background {background-color: " + Data + ";}"
399+ replacement_string = ".background {background-color: " + Data + ";}"
393400 self .css_text = re .sub (r'[.][b][a][c][k][g][r][o][u][n][d].*' , replacement_string , self .css_text , re .IGNORECASE )
394-
401+
395402 elif property == "labelcolor" :
396403 for widget in self .widgets :
397404 self .widgets [widget ].get_style_context ().remove_class ('labelcolor' )
398- replacement_string = ".labelcolor {color: " + Data + ";}"
405+ replacement_string = ".labelcolor {color: " + Data + ";}"
399406 self .css_text = re .sub (r'[.][l][a][b][e][l][c][o][l][o][r].*' , replacement_string , self .css_text , re .IGNORECASE )
400-
401- elif property == "size" :
407+
408+ elif property == "size" :
402409 for widget in self .widgets :
403410 self .widgets [widget ].get_style_context ().remove_class ('size_big' )
404411 self .widgets [widget ].get_style_context ().remove_class ('size_small' )
405- replacement_string = ".size_big {font-size: " + str (Data ) + "px;font-weight: bold;}"
412+ replacement_string = ".size_big {font-size: " + str (Data ) + "px;font-weight: bold;}"
406413 self .css_text = re .sub (r'[.][s][i][z][e][_][b][i][g].*' , replacement_string , self .css_text , re .IGNORECASE )
407- replacement_string = ".size_small {font-size: " + str (int (Data / 2.5 )) + "px;font-weight: bold;}"
414+ replacement_string = ".size_small {font-size: " + str (int (Data / 2.5 )) + "px;font-weight: bold;}"
408415 self .css_text = re .sub (r'[.][s][i][z][e][_][s][m][a][l][l].*' , replacement_string , self .css_text , re .IGNORECASE )
409416
410417 else :
411418 print ("Got unknown property in <<set_style>>" )
412419 return
413420
414421 self .css .load_from_data (bytes (self .css_text , 'utf-8' ))
415-
422+
416423 for widget in self .widgets :
417424 self .widgets [widget ].get_style_context ().add_class ('background' )
418425 self .widgets [widget ].get_style_context ().add_class ('labelcolor' )
419426 if widget in ("lbl_axisletter" , "main_dro" ):
420427 self .widgets [widget ].get_style_context ().add_class ('size_big' )
421428 else :
422429 self .widgets [widget ].get_style_context ().add_class ('size_small' )
423-
430+
424431 self .queue_draw ()
425432
426433 def _user_system_changed (self , object , system ):
@@ -492,7 +499,7 @@ def _not_all_homed(self, widget, data = None):
492499 if self .homed :
493500 self .set_style ("labelcolor" , self .homed_color )
494501 else :
495- self .set_style ("labelcolor" , self .unhomed_color )
502+ self .set_style ("labelcolor" , self .unhomed_color )
496503
497504 def _all_homed (self , widget , data = None ):
498505 if self .status .kinematics_type == linuxcnc .KINEMATICS_IDENTITY :
@@ -666,7 +673,8 @@ def get_position(self):
666673def main ():
667674 window = Gtk .Window (type = Gtk .WindowType .TOPLEVEL )
668675
669- vbox = Gtk .VBox (homogeneous = False , spacing = 5 )
676+ vbox = Gtk .Box (homogeneous = False , spacing = 5 )
677+ vbox .set_orientation (Gtk .Orientation .VERTICAL )
670678 MDRO_X = Combi_DRO (0 )
671679 MDRO_Y = Combi_DRO (1 )
672680 MDRO_Z = Combi_DRO (2 )
0 commit comments