fixed enable/disable buttons

master
idziubenko 3 years ago
parent 2c99ae9e40
commit 9669a6b501

@ -183,7 +183,7 @@ class ControlButtonWgt(qt.QWidget):
def add_custom_button(self, Group, x, y, brief=False,
next_button_text=""):
# self.del_button()
self.del_button()
buttons = self._parent.MainFrameWgt.buttons
self.button_widget = qt.QWidget(self)
end_layout = qt.QHBoxLayout(self.button_widget)
@ -226,7 +226,7 @@ class ControlButtonWgt(qt.QWidget):
def add_standart_button(self, Group, x, y, brief=False, \
next_button_text=""):
# self.del_button()
self.del_button()
main_frame = self._parent.MainFrameWgt
# add 1 (or 2) button ok (next) [and previous]
self.button_widget = qt.QWidget(self)
@ -337,29 +337,51 @@ class ControlButtonWgt(qt.QWidget):
self.default_button = self.next_button
def del_button(self):
# buttons will moslty be garbage collected
if self.button_widget:
self.hlayout.removeWidget(self.button_widget)
self.button_widget.close()
# self.button_widget = None
# only one of the buttons that actually needs to be closed
try:
self.button_widget.close()
print("WIDGET BUTTON CLOSED")
except Exception as e:
print(str(e) + f" (WIDGET BUTTON)")
self.button_widget = None
if self.prev_button:
self.prev_button.close()
# self.prev_button = None
# try:
# self.prev_button.close()
# print("PREV BUTTON CLOSED")
# except Exception as e:
# print(str(e) + f" (PREV BUTTON)")
self.prev_button = None
if self.cancel_button:
self.cancel_button.close()
# self.cancel_button = None
# try:
# self.cancel_button.close()
# print("CANCEL BUTTON CLOSED")
# except Exception as e:
# print(str(e) + f" (CANCEL BUTTON)")
self.cancel_button = None
if self.next_button:
self.next_button.close()
# self.next_button = None
# try:
# self.next_button.close()
# print("NEXT BUTTON CLOSED")
# except Exception as e:
# print(str(e) + f" (NEXT BUTTON)")
self.next_button = None
if self.customs:
for but in self.customs:
but.close()
# self.customs = None
# try:
# but.close()
# print("CUSTOM BUTTON CLOSED")
# except Exception as e:
# print(str(e) + f" (CUSTOM BUTTON)")
self.customs = None
if self.default_button:
pass
# self.default_button = None
self.default_button = None
def pre_add_button(self):
# self.del_button()
self.del_button()
# add 1 (or 2) button ok (next) [and previous]
self.button_widget = qt.QWidget(self)
end_layout = qt.QHBoxLayout(self.button_widget)
@ -402,7 +424,7 @@ class ControlButtonWgt(qt.QWidget):
if type(self.window()) == SelectedMethodWgt:
self.window().close()
else:
# self.del_button()
self.del_button()
self.hide()
self._parent.back()
@ -426,37 +448,42 @@ class ControlButtonWgt(qt.QWidget):
if type(self.window()) == SelectedMethodWgt:
self.window().close()
else:
# self.del_button()
self.del_button()
self.hide()
self._parent.back()
def button_disabled(self):
# if self.next_button:
# self.next_button.setDisabled(True)
# if self.prev_button:
# self.prev_button.setDisabled(True)
# if self.cancel_button:
# self.cancel_button.setDisabled(True)
# if self.clear_proc_cache_button:
# self.clear_proc_cache_button.setDisabled(True)
# if self.customs:
# for but in self.customs:
# but.setDisabled(True)
if self.next_button:
self.next_button.setDisabled(True)
if self.prev_button:
self.prev_button.setDisabled(True)
if self.cancel_button:
self.cancel_button.setDisabled(True)
if self.clear_proc_cache_button:
try:
self.clear_proc_cache_button.setDisabled(True)
except Exception as e:
print(str(e) + (" (Cache button)"))
if self.customs:
for but in self.customs:
but.setDisabled(True)
self.ClientObj.app.processEvents()
def button_enabled(self):
# if self.next_button:
# self.next_button.setEnabled(True)
# if self.prev_button:
# self.prev_button.setEnabled(True)
# if self.cancel_button:
# self.cancel_button.setEnabled(True)
# if self.clear_proc_cache_button:
# self.clear_proc_cache_button.setEnabled(True)
# if self.customs:
# for but in self.customs:
# but.setEnabled(True)
if self.next_button:
self.next_button.setEnabled(True)
if self.prev_button:
self.prev_button.setEnabled(True)
if self.cancel_button:
self.cancel_button.setEnabled(True)
if self.clear_proc_cache_button:
try:
self.clear_proc_cache_button.setEnabled(True)
except Exception as e:
print(str(e) + (" (Cache button)"))
if self.customs:
for but in self.customs:
but.setEnabled(True)
self.ClientObj.app.processEvents()
def keyPressEvent(self, e):

@ -29,8 +29,7 @@ import itertools
icon_system_path = ['/usr/share/icons/Calculate/16x16/client-gui']
icon_path = 'data/images/'
icon_names = ['console_ok.png', 'console_cancel.png']
data_files = list(itertools.product(icon_system_path, \
map (lambda x: [icon_path+x], icon_names)))
data_files = list(itertools.product(icon_system_path, [[icon_path+x] for x in icon_names]))
data_files.append(('/usr/share/pixmaps',['data/calculate-console-online.svg',
'data/calculate-console-offline.svg',

Loading…
Cancel
Save