コード例 #1
0
ファイル: wxmeerk40t.py プロジェクト: meerk40t/meerk40t
    def __init__(self, context, path):
        wx.App.__init__(self, 0)
        self.supported_languages = supported_languages
        import meerk40t.gui.icons as icons

        self.timer = wx.Timer(self, id=wx.ID_ANY)
        self.Bind(wx.EVT_TIMER, context._kernel.scheduler_main, self.timer)
        context._kernel.scheduler_handles_main_thread_jobs = False
        self.timer.Start(10)

        icons.DARKMODE = wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOW)[0] < 127
        icons.icon_r = 230
        icons.icon_g = 230
        icons.icon_b = 230
        Module.__init__(self, context, path)
        self.locale = None
        self.Bind(wx.EVT_CLOSE, self.on_app_close)
        self.Bind(wx.EVT_QUERY_END_SESSION, self.on_app_close)  # MAC DOCK QUIT.
        self.Bind(wx.EVT_END_SESSION, self.on_app_close)
        self.Bind(wx.EVT_END_PROCESS, self.on_app_close)
        # This catches events when the app is asked to activate by some other process
        self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate)

        # App started add the except hook
        sys.excepthook = handleGUIException
        wx.ToolTip.SetAutoPop(10000)
        wx.ToolTip.SetDelay(100)
        wx.ToolTip.SetReshow(0)
コード例 #2
0
ファイル: scene.py プロジェクト: meerk40t/meerk40t
    def __init__(self, context, path, gui, **kwargs):
        Module.__init__(self, context, path)
        Job.__init__(
            self,
            job_name="Scene-%s" % path,
            process=self.refresh_scene,
            conditional=lambda: self.screen_refresh_is_requested,
            run_main=True,
        )
        self.log = context.channel("scene")
        self.log_events = context.channel("scene-events")
        self.gui = gui
        self.hittable_elements = list()
        self.hit_chain = list()
        self.widget_root = SceneSpaceWidget(self)
        self.screen_refresh_lock = threading.Lock()
        self.interval = 1.0 / 60.0  # 60fps
        self.last_position = None
        self._down_start_time = None
        self._down_start_pos = None
        self._cursor = None
        self._reference = None  # Reference Object
        self.attraction_points = []  # Clear all
        self.compute = True
        self.has_background = False

        self.colors = GuiColors(self.context)

        self.screen_refresh_is_requested = True
        self.background_brush = wx.Brush(self.colors.color_background)

        # Stuff for magnet-lines
        self.magnet_x = []
        self.magnet_y = []
        self.magnet_attraction = 2
        # 0 off, `1..x` increasing strength (quadratic behaviour)

        self.magnet_attract_x = True  # Shall the X-Axis be affected
        self.magnet_attract_y = True  # Shall the Y-Axis be affected
        self.magnet_attract_c = True  # Shall the center be affected

        # Stuff related to grids and guides
        self.tick_distance = 0
        self.auto_tick = False  # by definition do not auto_tick
        self.reset_grids()

        self.tool_active = False
        self.grid_points = None  # Points representing the grid - total of primary + secondary + circular

        self._animating = list()
        self._animate_lock = threading.Lock()
        self._adding_widgets = list()
        self._animate_job = Job(
            self._animate_scene,
            job_name=f"Animate-Scene{path}",
            run_main=True,
            interval=1.0 / 60.0,
        )
        self._toast = None
コード例 #3
0
 def __init__(self, *args, **kwargs):
     Module.__init__(self, *args, **kwargs)
     if "log" in kwargs:
         channel = kwargs["log"]
         if isinstance(channel, str):
             channel = self.context.channel(channel, buffer_size=500)
     else:
         channel = self.context.channel("ch341/usb", buffer_size=500)
     Handler.__init__(self, channel, self._state_change)
コード例 #4
0
    def __init__(self, context, name, port=23):
        """
        Laser Server init.

        @param context: Context at which this module is attached.
        @param name: Name of this module
        @param port: Port being used for the server.
        """
        Module.__init__(self, context, name)
        self.port = port

        self.socket = None
        self.events_channel = self.context.channel("server-tcp-%d" % port)
        self.data_channel = self.context.channel("data-tcp-%d" % port)
        self.context.threaded(self.run_tcp_delegater,
                              thread_name="tcp-%d" % port,
                              daemon=True)
コード例 #5
0
    def __init__(self, context, name, port=23, udp_address=None):
        """
        Laser Server init.

        @param context: Context at which this module is attached.
        @param name: Name of this module.
        @param port: UDP listen port.
        """
        Module.__init__(self, context, name)
        self.port = port
        self.events_channel = self.context.channel("server-udp-%d" % port)

        self.udp_address = udp_address
        self.context.channel("%s/send" % name).watch(self.send)
        self.recv = self.context.channel("%s/recv" % name)

        self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.socket.settimeout(2)
        self.socket.bind(("", self.port))
        self.context.threaded(self.run_udp_listener,
                              thread_name=name,
                              daemon=True)
コード例 #6
0
ファイル: mwindow.py プロジェクト: meerk40t/meerk40t
 def __init__(self,
              width,
              height,
              context,
              path,
              parent,
              *args,
              style=-1,
              **kwds):
     if style == -1:
         if parent is None:
             style = wx.DEFAULT_FRAME_STYLE
         else:
             style = (wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT
                      | wx.TAB_TRAVERSAL)
     wx.Frame.__init__(self, parent, style=style)
     Module.__init__(self, context, path)
     self.root_context = context.root
     self.window_context = context.get_context(path)
     self.root_context.setting(bool, "windows_save", True)
     self.window_save = self.root_context.windows_save
     if self.window_save:
         self.window_context.setting(int, "width", width)
         self.window_context.setting(int, "height", height)
         if self.window_context.width < 100:
             self.window_context.width = 100
         if self.window_context.height < 100:
             self.window_context.height = 100
         self.SetSize(
             (self.window_context.width, self.window_context.height))
     else:
         self.SetSize(width, height)
     self.Bind(wx.EVT_CLOSE, self.on_close, self)
     self.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_left_down, self)
     self.Bind(wx.EVT_RIGHT_DOWN, self.on_menu_request, self)
     self.Bind(wx.EVT_MOVE, self.on_change_window, self)
     self.Bind(wx.EVT_SIZE, self.on_change_window, self)
コード例 #7
0
ファイル: lihuiyuemulator.py プロジェクト: meerk40t/meerk40t
    def __init__(self, context, path):
        Module.__init__(self, context, path)
        self.context.setting(bool, "fix_speeds", False)

        self.parser = LihuiyuParser()
        self.parser.fix_speeds = self.context.fix_speeds
        self.parser.channel = self.context.channel("lhy")

        def pos(p):
            if p is None:
                return
            x0, y0, x1, y1 = p
            self.context.signal(
                "emulator;position",
                (
                    x0 * UNITS_PER_MIL,
                    y0 * UNITS_PER_MIL,
                    x1 * UNITS_PER_MIL,
                    y1 * UNITS_PER_MIL,
                ),
            )

        self.parser.position = pos
        self._attached_device = None