mydialogs.pyΒΆ

This is the event handling script derived from the base dialog script mydialogsbase.py generated using wxFormBuilder template MyDialogs.fbp.

The event handling template file allows to override any virtual event handler used in the base script and to define new classes to cater for the needs of the application.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python


import wx
from nardascripting.base.signalsharkdev import *
from nardascripting.base.usrscriptbase import *
from nardascripting.base.measthread import *
from .mydialogsbase import MySettingsBaseDlg, MyMeasGUIBaseDlg
from . import scriptimages


class MySettingsDlg(MySettingsBaseDlg):
    """Settings dialog"""

    def __init__(self, parent):
        """Initialization"""
        super().__init__(parent)
        #self.lbl_my_label.SetLabelText(msg)


class MyMeasGUIDlg(MyMeasGUIBaseDlg):
    """Custom dialog class for data visualization."""

    def __init__(self, parent, title: str):
        """Dialog class for data visualization.

        :param parent: The parent window as wx.Window.
        """
        super().__init__(parent=parent)

        self.init_progress_bar(self.pgb_progress)
        self.init_dlg_buttons(self.sdbs_buttons, wx.OK)
        self.btn_ok.SetLabel('Quit')
        self.SetTitle(title)

        # Setup images
        self.bmp_symbol.SetBitmap(scriptimages.img_meas_symbol.GetBitmap())

        # self.Maximize(True)

    def update_progress(self, evt: ProgressEvent):
        """Receives data from thread and updates progressbar and message text

        :param evt: Event of type ProgressEvent.
        """

        # Handle progress
        self.update_progress_bar(evt, self.pgb_progress)

        # Handle message
        if evt.msg is not None:
            self.lbl_status.SetLabelText(evt.msg)

        # Handle data:
        if evt.data is not None:
            self.txt_my_meas_values.SetLabelText(str(evt.data))

        # Handle buttons:
        if evt.btn_style:
            self.update_btn_style(evt.btn_style)

        # Handle icons:
        if evt.icon_style:
            self.update_icon_style(self.bmp_icon, evt.icon_style)

        # Handle help text:
        if evt.help_text:
            self.help_text = evt.help_text

        self.Layout()
        self.Refresh()
        self.Update()

    # Code here --------------------------------------------------------------------------------------
    # Add more methods here if required
    # If virtual event handlers are used in MyMeasGUIBaseDlg, over-ride them here in the derived class
    # ------------------------------------------------------------------------------------------------


# This is just a python module containing helper classes/functions:
if __name__ == '__main__':
    pass

download example03.zip