コード例 #1
0
class CloseDialog(SimpleDialog):
    button_box = None
    close_btn = None
    left_button_box = None

    def __init__(self, parent, title, size=(-1, -1), style=VERTICAL,
                 resizable=True, on_load=None, add_line=True, margin=None):
        SimpleDialog.__init__(self, parent, title, size, style, resizable,
                              on_load, add_line, margin)

    def set_dialog_buttons(self):
        if self.add_line:
            self.box.pack(HLine(self.box), fill=True, padding=5)
        else:
            self.box.pack((3, 3))

        self.button_box = HPanel(self.box)
        self.box.pack(self.button_box, fill=True)

        self.close_btn = Button(self.button_box, '', onclick=self.on_close,
                                default=True, pid=const.BUTTON_CLOSE)

        self.left_button_box = HPanel(self.button_box)
        self.button_box.pack(self.left_button_box, expand=True, fill=True)
        self.button_box.pack(self.close_btn, padding=5)
コード例 #2
0
ファイル: modaldlgs.py プロジェクト: Scrik/sk1-wx
class CloseDialog(SimpleDialog):

	def __init__(self, parent, title, size=(-1, -1), style=VERTICAL,
				resizable=True, on_load=None, add_line=True):
		SimpleDialog.__init__(self, parent, title, size, style, resizable,
							on_load, add_line)

	def set_dialog_buttons(self):
		if self.add_line:
			self.box.pack(HLine(self.box), fill=True, padding=5)
		else:
			self.box.pack((3, 3))

		self.button_box = HPanel(self.box)
		self.box.pack(self.button_box, fill=True)

		self.close_btn = Button(self.button_box, '', onclick=self.on_close,
							default=True, pid=const.BUTTON_CLOSE)

		self.left_button_box = HPanel(self.button_box)
		self.button_box.pack(self.left_button_box, expand=True, fill=True)
		self.button_box.pack(self.close_btn, padding=5)
コード例 #3
0
ファイル: modaldlgs.py プロジェクト: devurandom/sk1-wx
class OkCancelDialog(SimpleDialog):
    sizer = None
    box = None
    button_box = None
    ok_btn = None
    cancel_btn = None
    action_button = None

    def __init__(
            self, parent, title, size=(-1, -1), style=VERTICAL,
            resizable=False, action_button=const.BUTTON_OK, on_load=None,
            add_line=True):
        self.action_button = action_button
        SimpleDialog.__init__(
            self, parent, title, size, style, resizable, on_load, add_line)

    def set_dialog_buttons(self):
        if self.add_line:
            self.box.pack(HLine(self.box), fill=True, padding=5)
        else:
            self.box.pack((3, 3))

        self.button_box = HPanel(self.box)
        self.box.pack(self.button_box, fill=True)

        self.ok_btn = Button(
            self.button_box, '', onclick=self.on_ok,
            default=True, pid=self.action_button)
        self.cancel_btn = Button(
            self.button_box, '', onclick=self.on_cancel,
            pid=const.BUTTON_CANCEL)

        self.left_button_box = HPanel(self.button_box)
        self.button_box.pack(self.left_button_box, expand=True, fill=True)

        if const.IS_MAC:
            self.button_box.pack(self.ok_btn, padding=5)
            self.button_box.pack(self.cancel_btn, padding=5)
        elif const.IS_MSW:
            self.button_box.pack(self.ok_btn, padding=2)
            self.button_box.pack(self.cancel_btn)
        else:
            self.button_box.pack(self.cancel_btn, padding=2)
            self.button_box.pack(self.ok_btn)

    def on_ok(self):
        self.end_modal(const.BUTTON_OK)

    def on_cancel(self):
        self.end_modal(const.BUTTON_CANCEL)

    def show(self):
        ret = None
        if self.show_modal() == const.BUTTON_OK:
            ret = self.get_result()
        self.destroy()
        return ret
コード例 #4
0
class CustomProgressDialog(SimpleDialog):
    label = None
    progressbar = None
    button_box = None
    cancel_btn = None
    result = None
    callback = None
    args = None
    msg = ''

    def __init__(self, parent, title, size=(500, 100), style=VERTICAL,
                 resizable=False, action_button=const.BUTTON_CANCEL,
                 add_line=False, margin=None,
                 button_box_padding=0):
        self.label = title
        self.action_button = action_button
        self.button_box_padding = button_box_padding
        SimpleDialog.__init__(self, parent, title, size, style, resizable,
                              self.on_load, add_line, margin)

    def build(self):
        self.panel.pack((5, 5))
        self.label = Label(self.panel, self.label)
        self.panel.pack(self.label, fill=True)
        self.progressbar = ProgressBar(self.panel)
        self.panel.pack(self.progressbar, fill=True, padding=15)

    def set_dialog_buttons(self):
        self.button_box = HPanel(self.box)
        self.box.pack(self.button_box, fill=True,
                      padding_all=self.button_box_padding)
        self.button_box.pack(HPanel(self.button_box), fill=True, expand=True)
        self.cancel_btn = Button(self.button_box, '', onclick=self.on_cancel,
                                 default=True, pid=const.BUTTON_CANCEL)
        self.cancel_btn.set_enable(False)
        self.button_box.pack(self.cancel_btn)
        self.fit()

    def on_cancel(self):
        self.end_modal(const.BUTTON_CANCEL)

    def show(self):
        self.show_modal()
        return self.result

    def update_data(self, value, msg):
        self.label.set_text(msg)
        self.label.Update()
        self.progressbar.set_value(value)
        self.progressbar.Update()
        self.Update()
        wx.Yield()

    def on_load(self, *args):
        self._timer.Stop()
        self.progressbar.set_value(5)
        try:
            if self.callback and self.args:
                self.result = self.callback(*self.args)
        except Exception as e:
            LOG.exception('Error in progress dialog running: %s', e)
        finally:
            self.progressbar.set_value(98)
            self.end_modal(const.BUTTON_CANCEL)

    def run(self, callback, args):
        self.callback, self.args = callback, args
        return self.show()
コード例 #5
0
ファイル: modaldlgs.py プロジェクト: Scrik/sk1-wx
class OkCancelDialog(SimpleDialog):

	sizer = None
	box = None
	button_box = None
	ok_btn = None
	cancel_btn = None
	action_button = None

	def __init__(self, parent, title, size=(-1, -1), style=VERTICAL,
				resizable=False, action_button=const.BUTTON_OK, on_load=None,
							add_line=True):
		self.action_button = action_button
		SimpleDialog.__init__(self, parent, title, size, style,
							resizable, on_load, add_line)

	def set_dialog_buttons(self):
		if self.add_line:
			self.box.pack(HLine(self.box), fill=True, padding=5)
		else:
			self.box.pack((3, 3))

		self.button_box = HPanel(self.box)
		self.box.pack(self.button_box, fill=True)

		self.ok_btn = Button(self.button_box, '', onclick=self.on_ok,
							pid=self.action_button)
		self.cancel_btn = Button(self.button_box, '', onclick=self.on_cancel,
							default=True, pid=const.BUTTON_CANCEL)

		self.left_button_box = HPanel(self.button_box)
		self.button_box.pack(self.left_button_box, expand=True, fill=True)

		if const.is_mac():
			self.button_box.pack(self.ok_btn, padding=5)
			self.button_box.pack(self.cancel_btn, padding=5)
		elif const.is_msw():
			self.button_box.pack(self.ok_btn, padding=2)
			self.button_box.pack(self.cancel_btn)
		else:
			self.button_box.pack(self.cancel_btn, padding=2)
			self.button_box.pack(self.ok_btn)

	def on_ok(self):
		self.end_modal(const.BUTTON_OK)

	def on_cancel(self):
		self.end_modal(const.BUTTON_CANCEL)

	def show(self):
		ret = None
		if self.show_modal() == const.BUTTON_OK:
			ret = self.get_result()
		self.destroy()
		return ret