Skip to content

Commit 9c93a92

Browse files
Avoid use of global for testing purpose
1 parent d109b06 commit 9c93a92

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

StarChart.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,7 @@ def get_planet_index(name):
764764
#
765765
# controls on menubar1 (_('what')):
766766
fullscreen = ToolButton('view-fullscreen')
767-
button1 = ToggleToolButton(icon_name='night-off')
768-
button1.set_tooltip(_('Night Vision'))
767+
769768
button2 = ToggleToolButton(icon_name='invert-off')
770769
button2.set_tooltip(_('Invert Display'))
771770
button3 = ToggleToolButton(icon_name='left-right')
@@ -1077,6 +1076,10 @@ def __init__(self, context):
10771076
Gdk.EventMask.BUTTON1_MOTION_MASK | Gdk.EventMask.BUTTON2_MOTION_MASK)
10781077
self.connect('button_press_event', self.pressing)
10791078
self.magnifying = False
1079+
self.nightvision = False
1080+
starchart = StarChart()
1081+
self.button1 = starchart.button1
1082+
10801083
self.mag_center = [0, 0]
10811084
if (not specifytime):
10821085
GObject.timeout_add(60000, self.timer1_cb)
@@ -1195,8 +1198,9 @@ def callback(self, widget, data=None):
11951198
if (data == None):
11961199
return False
11971200
elif (data == 'night vision'):
1198-
self.nightvision = button1.get_active()
1199-
button1.set_active(self.nightvision)
1201+
1202+
self.nightvision = self.button1.get_active()
1203+
self.button1.set_active(self.nightvision)
12001204
self.plotchart()
12011205
return False
12021206
elif (data == 'invert display'):
@@ -3041,12 +3045,15 @@ def __init__(self, handle):
30413045

30423046
# Fill the toolbox bars
30433047

3048+
self.button1 = ToggleToolButton(icon_name='night-off')
3049+
self.button1.set_tooltip(_('Night Vision'))
3050+
30443051
self._toolbar_add(self.what_toolbar, fullscreen)
30453052
separator = Gtk.SeparatorToolItem()
30463053
separator.props.draw = True
30473054
separator.set_expand(False)
30483055
self._toolbar_add(self.what_toolbar, separator)
3049-
self._toolbar_add(self.what_toolbar, button1)
3056+
self._toolbar_add(self.what_toolbar, self.button1)
30503057
self._toolbar_add(self.what_toolbar, button2)
30513058
self._toolbar_add(self.what_toolbar, button3)
30523059
self._toolbar_add(self.what_toolbar, button4)
@@ -3169,7 +3176,7 @@ def __init__(self, handle):
31693176
# Connect the control widget events.
31703177
self.nightvision = False
31713178
fullscreen.connect('clicked', self._fullscreen_callback)
3172-
button1.connect('clicked', self.chart.callback, 'night vision')
3179+
self.button1.connect('clicked', self.chart.callback, 'night vision')
31733180
button2.connect('clicked', self.chart.callback, 'invert display')
31743181
button3.connect('clicked', self.chart.callback, 'flip horizontally')
31753182
button4.connect('clicked', self.chart.callback, 'draw constellations')
@@ -3260,6 +3267,7 @@ def read_file(self, filename):
32603267
else:
32613268
zoneoffset = zoneoffset + mm
32623269
initialize_controls()
3270+
self.nightvision = False
32633271
self.chart.plotchart()
32643272

32653273
def write_file(self, filename):

0 commit comments

Comments
 (0)