Example #1
0
def main():
    parser = argparse.ArgumentParser(
        description="Winsnap: Snap windows into a customizable grid")
    parser.add_argument("--debug",
                        action="store_true",
                        help="Show the log window")
    args = parser.parse_args()
    main_window = MainWindow()

    def mouse_click_cb(sender, data):
        main_window.refresh_windows()

    def startup_cb(sender, data):
        main_window.load()

    dpg_core.set_mouse_click_callback(mouse_click_cb)
    dpg_core.set_start_callback(startup_cb)
    dpg_core.set_resize_callback(main_window.resize_callback,
                                 handler="Main Window")
    scale = ctypes.windll.shcore.GetScaleFactorForDevice(0) / 100
    dpg_core.set_global_font_scale(scale)
    w, h = dpg_core.get_main_window_size()
    dpg_core.set_main_window_size(int(w * scale), int(h * scale))
    dpg_core.set_main_window_title("WinSnap")
    if args.debug:
        dpg_core.show_logger()
    dpg_core.start_dearpygui(primary_window="Main Window")
Example #2
0
	def __init__(self):
		core.set_style_item_spacing(1, 1)
		core.set_style_window_padding(0, 0)
		core.set_main_window_size(690, 450)
		with simple.window("main"):
			core.add_drawing("canvas")
		core.set_resize_callback(self.__resize)
		core.set_render_callback(self.__render)
Example #3
0
	def __init__(self):
		core.set_main_window_size(720, 540)
		with simple.window("main"):
			with simple.group("group"):
				core.add_button("thread", label='Add Thread', callback=lambda s, d: self.__buttonThread())

		self.__bars = {}
		core.set_render_callback(lambda s, d: self.__render())
		core.set_resize_callback(lambda s, d: self.__resize())
Example #4
0
    def __init__(self):

        with simple.window(self.windowName):
            core.add_drawing(self.pictureName, width=1500, height=1500)
            core.draw_image(self.pictureName,
                            self.picturePath,
                            pmin=[0, 0],
                            pmax=[700, 700])
            core.set_resize_callback(callback=self.window_resize,
                                     handler=self.windowName)
        super().__init__()
Example #5
0
    def __init__(self):
        core.set_main_window_size(720, 540)
        self.__width = 17
        self.__height = 7
        self.__total = self.__width * self.__height
        self.__board = {}
        size = core.get_main_window_size()
        self.__paddle = [size[0] * .475, size[1] * .85]
        self.__paddleSize = (80, 8)
        # x, y, angle (rads), speed
        self.__radius = 6
        self.__speed = 300
        self.__paddleSpeed = 1000
        self.__speedMax = self.__speed * 3
        self.__pos = (size[0] * .5, size[1] * .8, 0, -self.__speed)

        with simple.window("main"):
            with simple.group("scoreboard"):
                core.add_label_text("score")
                core.add_same_line()
                core.add_text("score-value")
                # core.add_same_line()
                core.add_label_text("time")
                core.add_same_line()
                core.add_text("time-value")
            core.add_drawing("canvas", width=size[0], height=size[1])
            core.draw_circle("canvas",
                             size,
                             self.__radius, (255, 255, 255, 255),
                             fill=(128, 128, 128, 255),
                             tag="ball")
            core.draw_rectangle("canvas", [
                self.__paddle[0] - self.__paddleSize[0],
                self.__paddle[1] - self.__paddleSize[1]
            ], [
                self.__paddle[0] + self.__paddleSize[0],
                self.__paddle[1] + self.__paddleSize[1]
            ], (255, 255, 255, 255),
                                fill=(128, 128, 128, 255),
                                tag="paddle")

        core.set_resize_callback(self.__resize)
        core.set_render_callback(self.__render)
        core.set_key_down_callback(self.__keydown)
        core.set_mouse_wheel_callback(self.__mousewheel)
Example #6
0
 def set_resize_callback(callback: Callable):
     """Set a callback for when the main viewport is resized."""
     dpgcore.set_resize_callback(callback, handler='')
Example #7
0
 def resized(self, callback: PyGuiCallback) -> Callable:
     """Set resized callback, can be used as a decorator."""
     dpgcore.set_resize_callback(wrap_callback(callback), handler=self.id)
     return callback
Example #8
0
    def __init__(self):

        with simple.window(self.windowName, width=self.xSize, height=self.ySize, x_pos=self.xPos, y_pos=self.yPos):
                core.add_drawing(self.drawingName, width=self.widthMax, height=self.heightMax)
                core.set_resize_callback(callback=self.window_resize, handler=self.windowName)
        super().__init__()
                    with dpgs.group(name='Tile 6',
                                    horizontal=False,
                                    horizontal_spacing=0):

                        dpg.add_image_button('Demo 6',
                                             value='resources/tile_06.png',
                                             height=button_height,
                                             width=button_width,
                                             frame_padding=5,
                                             background_color=[0, 0, 0, 0],
                                             callback=start_process,
                                             callback_data='06')

                        with dpgs.group(name='tagline 6',
                                        horizontal=True,
                                        horizontal_spacing=0):
                            dpg.add_text('  ')
                            dpg.add_image(name='item 6',
                                          value='resources/blue_arrow.png')
                            dpg.add_text('\nTagline 6')

                # END OF TILES

                # add vertical spacing so last lines are shown when scrolling down
                dpg.add_spacing(count=8)

                # END OF BODY

    dpg.set_resize_callback(auto_center, handler='main window')
    # dpg.set_render_callback(auto_center)
    dpg.start_dearpygui(primary_window='main window')
Example #10
0
    def __init__(self):
        core.set_vsync(False)
        core.set_style_window_padding(0, 0)

        self.__iteration = 3
        # load the data blob

        root = path.dirname(path.realpath(__file__))
        with open(f'{root}/fractal.json', 'r') as data:
            self.__fractalData = OrderedDict(json.load(data))
        self.__fractalKeys = [k for k in self.__fractalData.keys()]
        d = self.__fractalKeys[0]
        self.__fractal = Fractal(**self.__fractalData[d])
        size = core.get_main_window_size()

        with simple.window("MainWindow"):
            with simple.group("Controls"):
                core.add_input_int("Iteration",
                                   width=120,
                                   min_value=2,
                                   max_value=40,
                                   min_clamped=True,
                                   max_clamped=True,
                                   default_value=self.__iteration,
                                   callback=self.__cbIterationValue)
                simple.tooltip(
                    "Iteration",
                    "How many times to re-run the pattern parser with the \
					previous runs output. Increasing this directly increases computation time."
                )

                with simple.group("Controls-Angle"):
                    core.add_input_float("Angle",
                                         width=120,
                                         default_value=self.__fractal.dAngle,
                                         callback=self.__cbAngleValue)
                    simple.tooltip(
                        "Angle",
                        "Degrees the turtle will turn either positive or negative, when issued such commands."
                    )
                    core.add_same_line()
                    core.add_checkbox("AngleAnimate",
                                      default_value=False,
                                      label="Animate")
                    core.add_input_float("AngleStep",
                                         width=120,
                                         default_value=.002,
                                         step=0.001,
                                         step_fast=0.01)
                    simple.tooltip(
                        "AngleStep",
                        "Amount the animator will step through the angle.")

                core.add_input_float("Length",
                                     width=120,
                                     default_value=self.__fractal.delta,
                                     callback=self.__cbDeltaValue)
                simple.tooltip(
                    "Length",
                    "Relative distance, forward or backward, the turtle will take when commanded."
                )
            core.add_same_line()
            core.add_listbox("power",
                             label='',
                             items=self.__fractalKeys,
                             callback=self.__cbFractalType)
            core.add_drawing("Canvas", width=size[0] * 2, height=size[1] * 2)
        core.set_resize_callback(self.__resize)
        core.set_render_callback(self.__render)
        self.__refresh()