def __init__(self, title='', text='', buttons=None, confirm_action=None, alphabet='', special_chars=latin_map, columns=None, eventhandler=None): ConfirmWindow.__init__(self, text=text, buttons=[]) self.title = title if not columns: columns = 12 self.columns = columns if not buttons: buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('OK'), True), Button(_('Cancel'), False)] buttons[0].connect(partial(self.change_special_char, -1)) buttons[1].connect(self.change_special_char) buttons[2].connect(self.delete_char) buttons[3].connect((confirm_action if confirm_action else KeyboardWindow.hide), self) buttons[4].connect(self.hide) for but in buttons: but.type = 'action' self.alphabet = self._KeyboardWindow__mk_text_button_list(alphabet) self.special_char_list = [] if not isinstance(special_chars, (list, tuple)): special_chars = [special_chars] for special_char in special_chars: self.special_char_list.append(self._KeyboardWindow__mk_text_button_list(special_char)) self.special_chars = self.special_char_list[0] self.action_buttons = buttons self.button_ranges = [self.alphabet, self.special_chars, buttons] self._uppercase_mode = False self._text_cursor_pos = len(self.text) self._reset_selection() self.change_special_char(0) self.eventhandler = (eventhandler if eventhandler else KeyboardEventHandler(self)) return None
def _KeyboardWindow__mk_text_button_list(self, char_string): ret = [] for char in char_string: but = Button(char, False) but.connect(self.insert_char) ret.append(but) return ret
def __init__(self, val, selected=True, min=-1000000, max=100000, cyclic=False): self.val = val self._max = max self._min = min self.cyclic = cyclic Button.__init__(self, '%d' % self.val, selected) return None
def _save_usb_mode(self): global glob_current_usb_mode, glob_current_ps3_fw, glob_usb_mode_orig try: if glob_current_usb_mode == 0: os.system('echo Mode MTP > /wymedia/usr/etc/usbcable.conf') os.system('echo %s >> /wymedia/usr/etc/usbcable.conf' % (glob_ps3_fw_dict[glob_current_ps3_fw])) self._update_initng(0) else: os.system('echo Mode PS3 > /wymedia/usr/etc/usbcable.conf') os.system('echo %s >> /wymedia/usr/etc/usbcable.conf' % (glob_ps3_fw_dict[glob_current_ps3_fw])) self._update_initng(1) if glob_usb_mode_orig != glob_current_usb_mode: w = ConfirmWindow(text=_( 'Modifications will take effect after reboot.\nDo you want to reboot now ?' ), confirm_action=self._reinit_box, buttons=[ Button(_('Yes'), False), Button(_('No'), True) ]) w.show() except: pass
def __init__(self, title='Search', text='', confirm_action=None): buttons = [Button(_('Exit'), False), Button(_('Delete'), False), Button(_('OK'), True)] buttons[0].connect(self.hide) buttons[1].connect(self.delete_char) buttons[2].connect((confirm_action if confirm_action else lambda: kdb.hide()), self) alphabet = '0123456789ABCDEF' KeyboardWindow.__init__(self, title=title, text=text, buttons=buttons, alphabet=alphabet, special_chars=['', '']) return None
def _check_action(self): w = ConfirmWindow(text=_( _('Modifications will take effect after reboot.\nDo you want to reboot now ?' )), confirm_action=self.restart_gui, buttons=[ Button(_('Yes'), False), Button(_('No'), True) ]) w.show()
def __init__(self, text='', buttons=None, confirm_action=None, confirm_args=()): Window.__init__(self) self._text = text if buttons is None: buttons = [Button(_('Yes'), True), Button(_('No'), False)] self.buttons = buttons self._reset_selection() self.eventhandler = ButtonListEventHandler(self) if confirm_action: buttons[0].connect(confirm_action, *(confirm_args if confirm_args else tuple())) return None
def apply_change(self): global glob_led_policy_etree glob_led_policy_etree.write('/etc/led_policy.xml', 'UTF-8') w = ConfirmWindow(text=_( 'Modifications will take effect after reboot.\nDo you want to reboot now ?' ), confirm_action=self._reinit_box, buttons=[ Button(_('Yes'), False), Button(_('No'), True) ]) w.show()
def __init__(self, title='Enter number:', value=0, confirm_action=None, columns=3): text = value if isinstance(value, int): text = str(value) elif isinstance(value, (float, long)): text = '%.2f' % value buttons = [Button(_('C'), False), Button(_('OK'), True), Button(_('Cancel'), False)] buttons[0].connect(self.delete_char) buttons[1].connect((confirm_action if confirm_action else lambda: kbd.hide()), self) buttons[2].connect(self.hide) KeyboardWindow.__init__(self, title=title, text=text, confirm_action=confirm_action, columns=columns, special_chars=['.'], alphabet='7894561230', buttons=buttons) return None
def __init__(self, buttons=None, alphabet='', special_chars=latin_map, insert_char_action=None, delete_char_action=None, columns=None, eventhandler=None): self._insert_char_action = insert_char_action self._delete_char_action = delete_char_action if not buttons: buttons = [Button('<<<', False), Button('>>>', False), Button(_('Delete'), False), Button(_('Hide'), False)] buttons[0].connect(partial(self.change_special_char, -1)) buttons[1].connect(self.change_special_char) buttons[2].connect(self.delete_char) buttons[3].connect(self.hide) for but in buttons: but.type = 'action' KeyboardWindow.__init__(self, '', '', buttons, None, alphabet, special_chars, columns, (eventhandler if eventhandler else SilentKeyboardEventHandler(self))) return None
def __init__(self, ip, title=_('IP address'), buttons=None, confirm_action=None, confirm_args=()): self.title = title self.modifiable_buttons = [IntegerButton(int(digit), False, 0, 255, True) for digit in ip.split('.', 3)] if not buttons: buttons = [Button(_('OK'), True), Button(_('Cancel'), False)] buttons[1].connect(self.hide) ConfirmWindow.__init__(self, text=ip, buttons=buttons, confirm_action=confirm_action, confirm_args=confirm_args) for but in buttons: but.type = 'action' self.buttons = self.modifiable_buttons + self.buttons self.eventhandler = MultiIntegerButtonsEventHandler(4, self) self.selected = self.modifiable_buttons[0] return None
def _check_action(self): from pygui.window.core import Button from pygui.window import ConfirmWindow w = ConfirmWindow(text=_( "You are about to reset the box. Are you sure you want to do it?\nIf 'Yes', box will reboot." ), confirm_action=self.reinit_box, buttons=[ Button(_('Yes'), False), Button(_('No'), True) ]) w.show() return None
def apply_change(self): global glob_setpoint_temp output_lines = [] input_file = os.popen('cat /etc/wyclim/pid.conf') input_lines = input_file.readlines() input_file.close() output = os.open('/etc/wyclim/pid.conf', (os.O_WRONLY | os.O_TRUNC)) for line in input_lines: if 'maxtemp' in line: os.write(output, ('maxtemp %d\n' % (glob_setpoint_temp * 1000))) else: os.write(output, line) os.close(output) w = ConfirmWindow(text=_( 'Modifications will take effect after reboot.\nDo you want to reboot now ?' ), confirm_action=self._reinit_box, buttons=[ Button(_('Yes'), False), Button(_('No'), True) ]) w.show()
def _check_action(self): w = ConfirmWindow(text=_('Are you sure ?'), confirm_action=self.reinit_box, buttons=[Button(_('Yes'), False), Button(_('No'), True)]) w.show()