Beispiel #1
0
    def __init__(self, parent, log):

        wx.Panel.__init__(self, parent)

        self.log = log
        self.mainPanel = wx.Panel(self)
        self.mainPanel.SetBackgroundColour(wx.WHITE)
        # Initialize GradientButton 1 (no image)
        self.btn1 = GB.GradientButton(self.mainPanel, -1, None, "Hello World!")
        # Initialize GradientButton 2 (with image)
        bitmap = wx.Bitmap(os.path.normpath(bitmapDir+"gradientbutton.png"), wx.BITMAP_TYPE_PNG)
        self.btn2 = GB.GradientButton(self.mainPanel, -1, bitmap, "GradientButton")

        self.topStartColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetTopStartColour(),
                                                  name="Top Start")
        self.topEndColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetTopEndColour(),
                                                name="Top End")
        self.bottomStartColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetBottomStartColour(),
                                                     name="Bottom Start")
        self.bottomEndColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetBottomEndColour(),
                                                   name="Bottom End")
        self.pressedTopColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetPressedTopColour(),
                                                    name="Pressed Top")
        self.pressedBottomColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetPressedBottomColour(),
                                                       name="Pressed Bottom")
        self.textColour = wx.ColourPickerCtrl(self.mainPanel, colour=self.btn2.GetForegroundColour(),
                                              name="Text Colour")

        self.DoLayout()
        self.BindEvents()
 def createSendb(self):
     self.sendb = GB.GradientButton(self.panel,
                                    wx.ID_ANY,
                                    None,
                                    "Send",
                                    size=(85, -1),
                                    pos=(20, 470))
     self.Bind(wx.EVT_BUTTON, self.onSendMail, self.sendb)
Beispiel #3
0
    def LoadHTMLPage(self):
        self.html_widget.SetPage('', '')
        self.html_pager_sizer.Clear(True)
        self.Layout()

        for key in self.parent_frame.dictImgOCR.keys():
            label_btn = key
            html_btn = GB.GradientButton(self.html_panel,
                                         -1,
                                         label=label_btn,
                                         name=label_btn)
            html_btn.Bind(wx.EVT_BUTTON, self.ChangeHtmlContent)
            self.html_pager_sizer.Add(html_btn, 0, wx.RIGHT, 20)

        # To Click on first button initially
        if len(self.parent_frame.dictImgOCR.keys()) > 0:
            btnName = list(self.parent_frame.dictImgOCR.keys())[0]
            self.UpdateHTMLPage(btnName)
            self.activeButton = btnName
Beispiel #4
0
    def __init__(self, parent, ID):
        # 初始化面板
        wx.Window.__init__(self, parent, ID)
        self.__parent = parent
        self.SetBackgroundColour("White")
        self.color = "Black"
        self.thickness = 1
        self.pen = wx.Pen(self.color, self.thickness, wx.SOLID)

        # 添加数独游戏
        self.margin = margin = 20
        self.sudoku = sudoku = c_sudoku.Sudoku((margin, margin))

        # 根据游戏大小重新设定窗体大小
        self.SetClientSizeWH(sudoku.get_width() + 2 * margin + 160,
                             sudoku.get_height() + 2 * margin)

        # 计时器
        self.elapsed_time = 0

        # 定时器
        self.timer = wx.Timer(self)

        # 添加计时文字
        self.textTimer = textTimer = wx.StaticText(self)
        textTimer.SetFont(wx.Font(24, wx.SWISS, wx.NORMAL, wx.BOLD))
        textTimer.SetForegroundColour("Gray")

        self.textProgress = textProgress = wx.StaticText(self)
        textProgress.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD))
        textProgress.SetForegroundColour("Gray")

        self.textFile = textFile = wx.StaticText(self)
        textFile.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))
        #textTimer.SetForegroundColour("Gray")

        # 添加按钮
        bitmap = wx.Bitmap(os.path.normpath("random.png"), wx.BITMAP_TYPE_PNG)
        self.btn_random = GB.GradientButton(
            self, -1, bitmap, u"随机游戏",
            (self.sudoku.get_width() + 2 * self.margin, self.margin +
             self.sudoku.GRID_WIDTH * 3 + (self.sudoku.GRID_WIDTH - 40) / 2),
            (120, 40))
        bitmap = wx.Bitmap(os.path.normpath("calc.png"), wx.BITMAP_TYPE_PNG)
        self.btn_auto_calc = GB.GradientButton(
            self, -1, bitmap, u"自动计算",
            (self.sudoku.get_width() + 2 * self.margin, self.margin +
             self.sudoku.GRID_WIDTH * 7 + (self.sudoku.GRID_WIDTH - 40) / 2),
            (120, 40))
        bitmap = wx.Bitmap(os.path.normpath("restart.png"), wx.BITMAP_TYPE_PNG)
        self.btn_restart = GB.GradientButton(
            self, -1, bitmap, u"重新开始",
            (self.sudoku.get_width() + 2 * self.margin, self.margin +
             self.sudoku.GRID_WIDTH * 8 + (self.sudoku.GRID_WIDTH - 40) / 2),
            (120, 40))

        self.file_cmb = file_cmb = wx.ComboBox(self,
                                               wx.NewId(),
                                               size=(100, 24),
                                               style=wx.CB_READONLY)
        for file_name in os.listdir("."):
            if file_name.endswith("pzl"):
                file_cmb.Append(file_name)
                file_cmb.SetValue(file_name)

        # 绑定事件
        self.Bind(wx.EVT_IDLE, self.OnIdle)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
        self.Bind(wx.EVT_CHAR, self.OnKeyDown)
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.Bind(wx.EVT_BUTTON, self.OnRestartButton, self.btn_restart)
        self.Bind(wx.EVT_BUTTON, self.OnAutoCalcButton, self.btn_auto_calc)
        self.Bind(wx.EVT_BUTTON, self.OnRandomButton, self.btn_random)

        # 开始游戏
        self.InitGame(
            "030500001050600002000802035010200706002000080704010200000100300006380000000006000"
        )
        #self.InitGame()
        self.ReBuffer()