def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) #, size=(600, 800)) # panel = wx.Panel(self, -1) panel = wx.PyScrolledWindow(self, -1, style=wx.HSCROLL | wx.VSCROLL | wx.ALWAYS_SHOW_SB) # panel.DoSetSize() # panel.SetScrollbars( 0, 5, 0, 20/5 ) # Pixels per scroll increment panel.SetScrollRate(3, 3) # Save whether to show results self.showResults = False # Create results in right panel self.resultsPanel = RightPanel(panel, -1) # Create fitting panel in left panel leftPanel = LeftPanel(panel, -1) self.hbox = wx.BoxSizer() self.hbox.Add(leftPanel, 1, wx.EXPAND | wx.ALL, 5) # if (self.showResults): self.hbox.Add(self.resultsPanel, 1, wx.EXPAND | wx.ALL, 5) panel.SetSizer(self.hbox) self.Update self.Show(True)
def __init__(self, directory): super(MainDialog, self).__init__(None, title='Position overview', size=(400, 800)) filenames = natural_sort([filename for filename in os.listdir(directory) if filename.endswith(".pos")]) panel = wx.PyScrolledWindow(self, -1) vbox = wx.BoxSizer(wx.VERTICAL) fgs = wx.FlexGridSizer(len(filenames), 3, 9, 25) for filename in filenames: label = wx.StaticText(panel, label=filename) gauge = wx.Gauge(panel, range=100, style=wx.GA_HORIZONTAL) gauge.Value = PercentageOfSolvedPositions(directory + '\\' + filename) percentage = wx.StaticText(panel, label = str(gauge.Value) + '%') fgs.AddMany([(label, 1, wx.EXPAND), (gauge), (percentage)]) fgs.AddGrowableCol(0, 1) vbox.Add(fgs, proportion=1, flag=wx.ALL|wx.EXPAND, border=10) panel.SetSizer(vbox) panel.SetScrollbar(0,0,0,0) panel.SetScrollRate(1, 1) self.Centre()
def ConvertToGreyscale(self, event): frame = wx.Frame(None, -1, 'Convert To Greyscale', pos=(0, 0)) self.frame2 = frame panel = wx.PyScrolledWindow(frame, style=wx.STAY_ON_TOP) img = wx.Image(self.imagePath, wx.BITMAP_TYPE_ANY).ConvertToGreyscale() self.newImage = img imageBox = wx.StaticBitmap(panel, wx.ID_ANY, wx.BitmapFromImage(img)) frame_size = self.AdjustFrameSize(img.GetSize()) scrollbar = self.IsEnableScrollbar(self.image.GetSize()) panel.EnableScrolling(scrollbar[0], scrollbar[1]) ratio = self.GetScrollbarRatio(self.image.GetSize()) panel.SetScrollbars(ratio[0], ratio[1], ratio[2], ratio[3]) panel.AdjustScrollbars() frame.SetClientSize(frame_size) panel.SetScale(0.1, 0.1) frame.SetMenuBar(self.MakeMenubar()) frame.Bind(wx.EVT_MENU, self.SaveImage, id=wx.ID_SAVE) frame.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN) frame.Bind(wx.EVT_MENU, self.OnClickExit, id=wx.ID_EXIT) frame.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT) frame.Bind(wx.EVT_MENU, self.OnCredit, id=ID_CREDIT) frame.Bind(wx.EVT_MENU, self.ConvertToGreyscale, id=ID_CONVERT_TO_GREYSCALE) frame.Bind(wx.EVT_MENU, self.ConvertToNegative, id=ID_CONVERT_TO_NEGATIVE) frame.SetClientSize(frame_size) frame.Show()
def __init__(self, redirect = False, filename = None): wx.App.__init__(self, redirect, filename) self.frame = wx.Frame(None, -1, title = 'Simple image viewer', size = (500, 500), pos = (0, 0)) self.panel = wx.PyScrolledWindow(self.frame, pos = (0,0)) self.frame.SetBackgroundColour("#FCFCFE") self.configuration() self.frame.SetMenuBar(self.MakeMenubar()) self.frame.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN) self.frame.Bind(wx.EVT_MENU, self.OnClickExit, id=wx.ID_EXIT) self.frame.Bind(wx.EVT_MENU, self.OnAbout, id =wx.ID_ABOUT) self.frame.Bind(wx.EVT_MENU, self.OnCredit, id = ID_CREDIT) self.frame.Bind(wx.EVT_MENU, self.ConvertToGreyscale, id = ID_CONVERT_TO_GREYSCALE) self.frame.Bind(wx.EVT_MENU, self.ConvertToNegative, id = ID_CONVERT_TO_NEGATIVE) self.frame.Bind(wx.EVT_MENU, self.ResizeImage, id = ID_RESIZE_IMAGE) self.frame.Bind(wx.EVT_MENU, self.Shrink, id = ID_SHRINK_IMAGE) self.frame.Bind(wx.EVT_MENU, self.WhatIsNew, id = ID_WHATISNEW) # Default parameters self.image = '' self.frame2 = '' self.status = self.frame.CreateStatusBar() self.savePath = '' self.imagePath = '' self.imageBox = '' self.frame.SetTitle(self.appname) self.panel.Layout() self.frame.Show()
def ConvertToGreyscale(self, event): frame = wx.Frame(None, -1, 'Convert To Greyscale', pos=(0, 0)) self.frame2 = frame panel = wx.PyScrolledWindow(frame, style=wx.STAY_ON_TOP) img = wx.Image(self.imagePath, wx.BITMAP_TYPE_ANY).ConvertToGreyscale() self.newImage = img imageBox = wx.StaticBitmap(panel, wx.ID_ANY, wx.BitmapFromImage(img)) frame_size = self.AdjustFrameSize(img.GetSize()) scrollbar = self.IsEnableScrollbar(frame_size) panel.EnableScrolling(scrollbar[0], scrollbar[1]) ratio = self.GetScrollbarRatio(frame_size) panel.SetScrollbars(ratio[0], ratio[1], ratio[2], ratio[3]) panel.AdjustScrollbars() frame.SetClientSize(frame_size) panel.SetScale(0.1, 0.1) menubar = wx.MenuBar() menu_File = wx.Menu() menu_File.Append(wx.ID_SAVE, '&Save', 'Save') menu_File.Append(wx.ID_EXIT, '&Exit', 'Exit') menubar.Append(menu_File, '&File') frame.SetMenuBar(menubar) frame.Bind(wx.EVT_MENU, self.SaveImage, id=wx.ID_SAVE) frame.Bind(wx.EVT_MENU, self.CloseWindow, id=wx.ID_EXIT) frame.SetClientSize(frame_size) frame.Show()
def __init__(self, parent, base_axis, data): wx.Dialog.__init__(self, parent, 0, size=(500, 400), style=wx.THICK_FRAME | wx.OK) self.base_axis = base_axis self.checkboxes = list() self.data = data if self.base_axis: self.text = "This dialogue box will change the base axis for the one diemsional plots, right now the base axis is %s" % self.base_axis.upper( ) else: self.text = "This dialogue box will change the base axis for the one diemsional plots, right now the base axis is %s" % "NORMAL PYTHON RANGE" self.checkbox = None self.selected_checkboxes = list() self.scroll = wx.PyScrolledWindow( self, -1, ) self.panel = wx.Panel(self.scroll, -1) self.grid_sizer = wx.FlexGridSizer(len(self.data.columns), 2, 0, 2) self.grid_sizer.Add(wx.StaticText(self.panel, -1, self.text)) self.grid_sizer.Add((20, 20)) self.populate_variables() btnOk = wx.Button(self.panel, wx.ID_OK) btnCancel = wx.Button(self.panel, wx.ID_CANCEL) self.btnSizer = wx.StdDialogButtonSizer() self.btnSizer.AddButton(btnOk) self.btnSizer.AddButton(btnCancel) self.btnSizer.Realize() self.box = wx.BoxSizer(wx.VERTICAL) self.box.Add(self.grid_sizer, proportion=1, flag=wx.ALL, border=20) self.box.Add(self.btnSizer) self.panel.SetSizer(self.box) self.panel.SetAutoLayout(True) self.panel.Layout() self.panel.Fit() self.Center() self.frmPanelWid, self.frmPanelHgt = self.panel.GetSize() self.unit = 1 self.scroll.SetScrollbars(self.unit, self.unit, self.frmPanelWid / self.unit, self.frmPanelHgt / self.unit)
def ResizeImage(self, event): frame = wx.Frame(None, -1, 'Resize Image', pos=(0, 0)) self.frame2 = frame panel = wx.PyScrolledWindow(frame, style=wx.STAY_ON_TOP) w = self.image.GetWidth() h = self.image.GetHeight() getWidth = wx.TextEntryDialog(None, message="Enter new width (current: " + str(w) + "): ", caption="Resize Image", defaultValue=str(w)) if getWidth.ShowModal() == wx.ID_OK: w = getWidth.GetValue() getHeight = wx.TextEntryDialog( None, message="Enter new width (current: " + str(h) + "): ", caption="Resize Image", defaultValue=str(h)) if getHeight.ShowModal() == wx.ID_OK: h = getHeight.GetValue() self.newImage = self.image.Scale((int)(w), (int)(h)) img = self.newImage imageBox = wx.StaticBitmap(panel, wx.ID_ANY, wx.BitmapFromImage(img)) frame_size = self.AdjustFrameSize(img.GetSize()) scrollbar = self.IsEnableScrollbar(frame_size) panel.EnableScrolling(scrollbar[0], scrollbar[1]) ratio = self.GetScrollbarRatio(frame_size) panel.SetScrollbars(ratio[0], ratio[1], ratio[2], ratio[3]) panel.AdjustScrollbars() frame.SetClientSize(frame_size) panel.SetScale(0.1, 0.1) frame.SetMenuBar(self.MakeMenubar()) frame.SetMenuBar(self.MakeMenubar()) frame.Bind(wx.EVT_MENU, self.SaveImage, id=wx.ID_SAVE) frame.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN) frame.Bind(wx.EVT_MENU, self.OnClickExit, id=wx.ID_EXIT) frame.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT) frame.Bind(wx.EVT_MENU, self.OnCredit, id=ID_CREDIT) frame.Bind(wx.EVT_MENU, self.ConvertToGreyscale, id=ID_CONVERT_TO_GREYSCALE) frame.Bind(wx.EVT_MENU, self.ConvertToNegative, id=ID_CONVERT_TO_NEGATIVE) frame.SetClientSize(frame_size) frame.Show()
def __init__(self, redirect=False, filename=None): wx.App.__init__(self, redirect, filename) self.frame = wx.Frame(None, -1, title='Simple image viewer', size=(500, 500), pos=(0, 0)) self.panel = wx.PyScrolledWindow(self.frame, pos=(0, 0)) self.configuration() self.frame.SetMenuBar(self.MakeMenubar()) self.frame.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN) self.frame.Bind(wx.EVT_MENU, self.OnClickExit, id=wx.ID_EXIT) self.frame.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT) self.frame.Bind(wx.EVT_MENU, self.OnCredit, id=ID_CREDIT) self.frame.Bind(wx.EVT_MENU, self.ConvertToGreyscale, id=ID_CONVERT_TO_GREYSCALE) self.frame.Bind(wx.EVT_MENU, self.ConvertToNegative, id=ID_CONVERT_TO_NEGATIVE) self.frame.Bind(wx.EVT_MENU, self.ResizeImage, id=ID_RESIZE_IMAGE) self.hBox = wx.BoxSizer() self.vBox = wx.BoxSizer(wx.VERTICAL) self.vBox.Add(self.hBox, proportion=1, flag=wx.EXPAND, border=0) self.imagePath = DEF_IMAGE tmpImg = wx.Image(self.imagePath, wx.BITMAP_TYPE_ANY) self.frame.SetClientSize(tmpImg.GetSize()) self.imageBox = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(tmpImg)) self.hBox.Add(self.imageBox, proportion=1, flag=wx.EXPAND, border=0) # Default parameters self.image = tmpImg self.frame2 = '' self.status = self.frame.CreateStatusBar() self.savePath = "" self.newImage = "" self.status.SetStatusText( str(tmpImg.GetWidth()) + "x" + str(tmpImg.GetHeight())) self.frame.SetTitle(self.appname + " - " + self.imagePath) self.panel.Layout() self.frame.Show()
def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, "Ulubione", size=(600, 700)) window = wx.PyScrolledWindow(self, -1) window.SetBackgroundColour('white') logofile = pwd + "logo.png" logopng = scale(logofile, 120, 100) wx.StaticBitmap(window, -1, logopng, (40, 10), (logopng.GetWidth(), logopng.GetHeight())) text = wx.StaticText(window, -1, 'Ulubione przepisy', (230, 80)) text.SetForegroundColour((0, 0, 0)) font = wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL) text.SetFont(font) buttons = [] try: favpath = pwd + "data/favorite.dat" favfile = open(favpath, 'r') names = favfile.readlines() i = -1 for name in names: i = names.index(name) fotofile = pwd + "data/images/img_" + replace( name[:-1]) + ".jpg" img = scale(fotofile, 180, 150) wx.StaticBitmap(window, -1, img, (50, 140 + 110 * i), (logopng.GetWidth(), logopng.GetHeight())) text = wx.StaticText(window, -1, name[:-1], (180, 160 + 110 * i), style=wx.ALIGN_LEFT) text.SetForegroundColour((0, 0, 0)) text.Wrap(300) button = wx.Button(window, -1, "Zobacz przepis", (470, 200 + 110 * i)) button.SetBackgroundColour((50, 50, 50)) button.SetForegroundColour('white') buttons.append(button) buttons[i].Bind(wx.EVT_BUTTON, lambda event, i=i: imgEvent( (names[i])[:-1], self)) if i >= 0: y = 250 + 110 * i window.SetScrollbars(0, 50, 0, y / 50 + 1) window.SetScrollRate(1, 1) except IOError: text = wx.StaticText(window, -1, 'Brak przepisów', (230, 150)) text.SetForegroundColour((0, 0, 0))
def ConvertToNegative(self, event): frame = wx.Frame(None, -1, 'Convert To Negative', pos=(0, 0)) self.frame2 = frame panel = wx.PyScrolledWindow(frame, style=wx.STAY_ON_TOP) img = wx.Image(self.imagePath, wx.BITMAP_TYPE_ANY) wx.SetCursor(wx.StockCursor(wx.CURSOR_ARROWWAIT)) progress = wx.ProgressDialog(title="Converting to negative", message="Processing", maximum=img.GetWidth(), parent=frame, style=wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME) for i in range(img.GetWidth()): progress.Update(i) for j in range(img.GetHeight()): img.SetRGB(i, j, 255 - img.GetRed(i, j), 255 - img.GetGreen(i, j), 255 - img.GetRed(i, j)) wx.SetCursor(self.cursor) progress.Destroy() self.newImage = img imageBox = wx.StaticBitmap(panel, wx.ID_ANY, wx.BitmapFromImage(img)) frame_size = self.AdjustFrameSize(img.GetSize()) scrollbar = self.IsEnableScrollbar(frame_size) panel.EnableScrolling(scrollbar[0], scrollbar[1]) ratio = self.GetScrollbarRatio(frame_size) panel.SetScrollbars(ratio[0], ratio[1], ratio[2], ratio[3]) panel.AdjustScrollbars() frame.SetClientSize(frame_size) panel.SetScale(0.1, 0.1) frame.SetMenuBar(self.MakeMenubar()) frame.SetMenuBar(self.MakeMenubar()) frame.Bind(wx.EVT_MENU, self.SaveImage, id=wx.ID_SAVE) frame.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN) frame.Bind(wx.EVT_MENU, self.OnClickExit, id=wx.ID_EXIT) frame.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT) frame.Bind(wx.EVT_MENU, self.OnCredit, id=ID_CREDIT) frame.Bind(wx.EVT_MENU, self.ConvertToGreyscale, id=ID_CONVERT_TO_GREYSCALE) frame.Bind(wx.EVT_MENU, self.ConvertToNegative, id=ID_CONVERT_TO_NEGATIVE) frame.SetClientSize(frame_size) frame.Show()
def InitUI(self, list_text): pnl = wx.PyScrolledWindow(self,-1) vbox = wx.BoxSizer(wx.VERTICAL) vbox1 = wx.BoxSizer(wx.VERTICAL) x = 20 # Magic numbers !? y = 20 self.radioBtnList = [] for text in list_text: self.radioBtnList.append(wx.RadioButton(pnl, label=text)) for R in self.radioBtnList: w, h = R.GetSize() dy = h + 10 # calculate for next loop y += dy vbox1.Add(R) pnl.SetScrollbars( 0, dy, 0, y/dy+1 ) pnl.SetScrollRate( 1, 1 ) # Pixels per scroll increment pnl.SetSizer(vbox1) hbox2 = wx.BoxSizer(wx.HORIZONTAL) okButton = wx.Button(self, label='Ok') closeButton = wx.Button(self, label='Close') hbox2.Add(okButton) hbox2.Add(closeButton, flag=wx.LEFT, border=5) vbox.Add(pnl, proportion=1, flag=wx.ALL|wx.EXPAND, border=5) vbox.Add(hbox2, flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=10) self.SetSizer(vbox) okButton.Bind(wx.EVT_BUTTON, self.OnOk) closeButton.Bind(wx.EVT_BUTTON, self.OnClose)
def __init__(self, parent, id, title, names): wx.Frame.__init__(self, parent, id, title, size=(600, 700)) window = wx.PyScrolledWindow(self, -1) window.SetBackgroundColour('white') logofile = pwd + "logo.png" logopng = scale(logofile, 120, 100) wx.StaticBitmap(window, -1, logopng, (40, 10), (logopng.GetWidth(), logopng.GetHeight())) text = wx.StaticText(window, -1, 'Lista wyników:', (230, 80)) text.SetForegroundColour((0, 0, 0)) font = wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL) text.SetFont(font) buttons = [] i = -1 for name in names: i = names.index(name) fotofile = pwd + "data/images/img_" + replace(name) + ".jpg" img = scale(fotofile, 180, 150) wx.StaticBitmap(window, -1, img, (50, 140 + 110 * i), (logopng.GetWidth(), logopng.GetHeight())) text = wx.StaticText(window, -1, name, (180, 160 + 110 * i), style=wx.ALIGN_LEFT) text.SetForegroundColour((0, 0, 0)) text.Wrap(300) button = wx.Button(window, -1, "Zobacz przepis", (470, 200 + 110 * i)) button.SetBackgroundColour((50, 50, 50)) button.SetForegroundColour('white') buttons.append(button) buttons[i].Bind(wx.EVT_BUTTON, lambda event, i=i: imgEvent(names[i], self)) if i >= 0: y = 250 + 110 * i window.SetScrollbars(0, 50, 0, y / 50 + 1) window.SetScrollRate(1, 1) button1 = wx.Button(window, -1, "Wstecz", (500, 2)) button1.SetBackgroundColour((50, 50, 50)) button1.SetForegroundColour('white') button1.Bind(wx.EVT_BUTTON, lambda event: Back(parent))
def __init__(self): wx.Frame.__init__(self, None, -1, "FicheFrame", size=(300, 400)) scrollWin = wx.PyScrolledWindow(self, -1) x = 20 # Magic numbers !? y = 20 for i in range(50): txtStr = " Text %02d : " % (i + 1) stTxt = wx.StaticText(scrollWin, -1, txtStr, pos=(x, y)) w, h = stTxt.GetSize() txtCtrl = wx.TextCtrl(scrollWin, -1, pos=(x + w + 5, y)) dy = h + 10 # calculate for next loop y += dy # end for scrollWin.SetScrollbars(0, dy, 0, y / dy + 1) scrollWin.SetScrollRate(1, 1) # Pixels per scroll increment
def Shrink(self, event): frame = wx.Frame(None, -1, 'Resize Image', pos = (0,0)) self.frame2 = frame panel = wx.PyScrolledWindow(frame, style = wx.STAY_ON_TOP) scaleX = 1 scaleY = 1 getScaleX = wx.TextEntryDialog(None, message = "Enter x factor (current: " + str(1) + "): ", caption = "Shrink Image", defaultValue = str(2)) if getScaleX.ShowModal() == wx.ID_OK: scaleX = getScaleX.GetValue() getScaleY = wx.TextEntryDialog(None, message = "Enter y factor (current: " + str(1) + "): ", caption = "Shrink Image", defaultValue = str(2)) if getScaleY.ShowModal() == wx.ID_OK: scaleY = getScaleY.GetValue() else: frame.Destroy() self.newImage = self.image.ShrinkBy((float) (scaleX), (float) (scaleY)) img = self.newImage imageBox = wx.StaticBitmap(panel, wx.ID_ANY, wx.BitmapFromImage(img)) frame_size = self.AdjustFrameSize(img.GetSize()) scrollbar = self.IsEnableScrollbar(frame_size) panel.EnableScrolling(scrollbar[0], scrollbar[1]) ratio = self.GetScrollbarRatio(frame_size) panel.SetScrollbars(ratio[0], ratio[1], ratio[2], ratio[3]) panel.AdjustScrollbars() frame.SetClientSize(frame_size) panel.SetScale(0.1, 0.1) frame.SetMenuBar(self.MakeMenubar()) frame.Bind(wx.EVT_MENU, self.SaveImage, id = wx.ID_SAVE) frame.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN) frame.Bind(wx.EVT_MENU, self.OnClickExit, id=wx.ID_EXIT) frame.Bind(wx.EVT_MENU, self.OnAbout, id =wx.ID_ABOUT) frame.Bind(wx.EVT_MENU, self.OnCredit, id = ID_CREDIT) frame.Bind(wx.EVT_MENU, self.ConvertToGreyscale, id = ID_CONVERT_TO_GREYSCALE) frame.Bind(wx.EVT_MENU, self.ConvertToNegative, id = ID_CONVERT_TO_NEGATIVE) frame.Bind(wx.EVT_MENU, self.ResizeImage, id = ID_RESIZE_IMAGE) frame.Bind(wx.EVT_MENU, self.Shrink, id = ID_SHRINK_IMAGE) frame.Bind(wx.EVT_MENU, self.WhatIsNew, id = ID_WHATISNEW) frame.SetClientSize(frame_size) frame.Show()
def InitUI(self): ico = wx.Icon('lg.ico', wx.BITMAP_TYPE_ICO) self.SetIcon(ico) self.img_orig = wx.Image(self.diffFile, wx.BITMAP_TYPE_BMP) img = Image.open(self.diffFile, 'r') self.img_size = img.size self.img_scale = 1 self.pnl = wx.PyScrolledWindow(self, -1) self.pnl.SetScrollbars(1, 1, self.img_size[0], self.img_size[1]) vbox = wx.BoxSizer(wx.HORIZONTAL) # Create a static bitmap for image to be put on looking glass self.bitmap_UGLASS = wx.StaticBitmap( self.pnl, wx.ID_ANY, wx.Bitmap(self.diffFile, wx.BITMAP_TYPE_ANY)) vbox.Add(self.bitmap_UGLASS, proportion=1, flag=wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, border=5) topSizer = wx.BoxSizer(wx.VERTICAL) topSizer.Add(vbox, 0, wx.CENTER) self.pnl.SetSizer(topSizer) # initialize rubber bands self.rBand = wxPyRubberBander(self.bitmap_UGLASS) self.rBand.setSources(self.fileName, self.source1, self.source2, self.diffFile) self.Bind(wx.EVT_SIZE, self.resize_space) self.Bind(wx.EVT_MOUSEWHEEL, self.set_scale) self.Bind(wx.EVT_KEY_UP, self.OnKeyDown) self.SetFocus()
def CropImage(self, event): def CloseWindow(self, event): self.frame2.Destroy() self.frame2 = wx.Frame(self.frame, -1, 'Select crop position', pos = (0,0), size = (300, 200)) panel = wx.PyScrolledWindow(self.frame2) xA_label = wx.StaticText(panel, -1, 'xA', pos = (10, 20), size = (80, 20), style = wx.ALIGN_CENTER) self.xA = wx.SpinCtrl(panel, -1, '', pos = (100, 20), size = (80, 20), style = wx.SP_WRAP) self.xA.SetRange(0, self.image.GetHeight()) yA_label = wx.StaticText(panel, -1, 'yA', pos = (10, 50), size = (80, 20), style = wx.ALIGN_CENTER) self.yA = wx.SpinCtrl(panel, -1, '', pos = (100, 50), size = (80, 20), style = wx.SP_WRAP) self.yA.SetRange(0, self.image.GetWidth()) xB_label = wx.StaticText(panel, -1, 'xB', pos = (10, 80), size = (80, 20), style = wx.ALIGN_CENTER) self.xB = wx.SpinCtrl(panel, -1, '', pos = (100, 80), size = (80, 20), style = wx.SP_WRAP) self.xB.SetRange(0, self.image.GetHeight()) yB_label = wx.StaticText(panel, -1, 'yB', pos = (10, 110), size = (80, 20), style = wx.ALIGN_CENTER) self.yB = wx.SpinCtrl(panel, -1, '', pos = (100, 110), size = (80, 20), style = wx.SP_WRAP) self.yB.SetRange(0, self.image.GetWidth()) ok_btn = wx.Button(panel, wx.NewId(), label = 'OK', pos = (200, 30), size = (60, 20), style = wx.ID_OK) cancel_btn = wx.Button(panel, wx.NewId(), label = 'Cancel', pos = (200, 100), size = (60, 20), style = wx.ID_CANCEL) self.frame2.Bind(wx.EVT_BUTTON, self.CropImageSelection, id = ok_btn.GetId()) self.frame2.Bind(wx.EVT_BUTTON, self.CloseExtraWindow, id = cancel_btn.GetId()) self.frame2.Show()
def ConvertToNegative(self, event): frame = wx.Frame(None, -1, 'Convert To Negative', pos=(0, 0)) self.frame2 = frame panel = wx.PyScrolledWindow(frame, style=wx.STAY_ON_TOP) img = self.image wx.SetCursor(wx.StockCursor(wx.CURSOR_ARROWWAIT)) for i in range(img.GetWidth()): for j in range(img.GetHeight()): img.SetRGB(i, j, 255 - img.GetRed(i, j), 255 - img.GetGreen(i, j), 255 - img.GetRed(i, j)) wx.SetCursor(self.cursor) self.newImage = img imageBox = wx.StaticBitmap(panel, wx.ID_ANY, wx.BitmapFromImage(img)) frame_size = self.AdjustFrameSize(img.GetSize()) scrollbar = self.IsEnableScrollbar(frame_size) panel.EnableScrolling(scrollbar[0], scrollbar[1]) ratio = self.GetScrollbarRatio(frame_size) panel.SetScrollbars(ratio[0], ratio[1], ratio[2], ratio[3]) panel.AdjustScrollbars() frame.SetClientSize(frame_size) panel.SetScale(0.1, 0.1) menubar = wx.MenuBar() menu_File = wx.Menu() menu_File.Append(wx.ID_SAVE, '&Save', 'Save') menu_File.Append(wx.ID_EXIT, '&Exit', 'Exit') menubar.Append(menu_File, '&File') frame.SetMenuBar(menubar) frame.Bind(wx.EVT_MENU, self.SaveImage, id=wx.ID_SAVE) frame.Bind(wx.EVT_MENU, self.CloseWindow, id=wx.ID_EXIT) frame.SetClientSize(frame_size) frame.Show()
def __init__(self, data): """ Class Variables: self.data: data which is to be plotted. self.x_data: slice of the self.data alongthe x-axis self.y_data: slice of the self.data alongthe y-axis self.z_data: slice of the self.data alongthe z-axis. self.minimum: Intialised with the value 0, Default slicing for the data self.maximum: Intialised with the value 10000, Default slicing of the data, Both these class variable implies that the Intial plot data will be plotted from data[self.minimum: self.maximum] Their values can be changed from the "Go Plot!!" button present at the end of the Frame. self.log_panel: wx.Panel which will have the standard input and out bound to it. self.New_Tab: wx.Notebook which is opened as a new tab whenever the new tab option is clicked from the file menu. """ self.selected_checkboxes = list() self.axis_3d = True self.tab_count = 0 self.minimum = 0 self.maximum = 1000 self.data = data self.x_data= None self.y_data= None self.z_data= None self.base_axis = None wx.Frame.__init__(self, None, -1, size=(800,600), pos=((wx.DisplaySize()[0])/2,(wx.DisplaySize()[1])/2), style=wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX) self.Button_vbox= wx.BoxSizer(wx.VERTICAL) #Splitter window self.window= wx.SplitterWindow(self, wx.ID_ANY, style=wx.SP_3D | wx.SP_BORDER, size=(800,600)) #Two panels self.left_panel = wx.Panel(self.window, wx.ID_ANY) self.right_panel = wx.Panel(self.window, wx.ID_ANY) #Notebook on which the matplotlib panel will be inserted self.New_Tab = fnb.FlatNotebook(self.right_panel, style=fnb.FNB_TABS_BORDER_SIMPLE|fnb.FNB_VC71) font = wx.Font(6, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Comic Sans MS') font_bottom = wx.Font(7, wx.FONTFAMILY_TELETYPE, wx.FONTFAMILY_DECORATIVE, wx.FONTWEIGHT_BOLD, True, u'Comic Sans MS') self.matplotlib_panel= MatplotlibPanel(self.New_Tab, self.tab_count, self.data, self.minimum, self.maximum) self.New_Tab.AddPage(self.matplotlib_panel, "Tab %s"%self.tab_count) self.tab_count += 1 #This panel will have all the varibales present in the data file self.wxpanel= wx.PyScrolledWindow(self.left_panel, -1,) self.wxpanel.SetFont(font_bottom) self.wxpanel.SetBackgroundColour("DARKCYAN") self.log_window = wx.TextCtrl(self.left_panel, wx.ID_ANY, size=(300, 150), style = wx.TE_MULTILINE|wx.VSCROLL|wx.TE_BESTWRAP| wx.TE_WORDWRAP) self.log_window.SetFont(font) #This method populates the variable spresent in the file into the scrolled window self.checkbox_list = list() self.populate_variables(self.data, self.wxpanel, self.checkbox_list) self.vbox_left = wx.BoxSizer(wx.VERTICAL) self.vbox_left.Add(self.log_window, 0, wx.EXPAND| wx.ALL, 2) self.vbox_left.Add(self.wxpanel, 1, wx.EXPAND| wx.ALL, 2) self.left_panel.SetSizer(self.vbox_left) self.vbox_right = wx.BoxSizer(wx.VERTICAL) self.vbox_right.Add(self.New_Tab, 20, wx.EXPAND| wx.ALL, 1) self.right_panel.SetSizer(self.vbox_right) #This part generates the menu from the menu.xml present in the same directory menudata = XMLParser.xml_data("menu.xml") XMLParser.createMenus(self, menudata, self) sizer = wx.BoxSizer(wx.VERTICAL) self.window.SplitVertically(self.left_panel, self.right_panel) sizer.Add(self.window, 1, wx.EXPAND, 0) self.SetSizer(sizer) sizer.Fit(self) #This part redirects the standard output and standard input on the console embedded in the wx.Frame redir = RedirectText(self.log_window) sys.stdout = redir sys.stderr = redir # self.SetSizer(self.hbox) self.SetBackgroundColour("light blue") self.statusbar = self.CreateStatusBar() self.Centre() self.Show()
def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(600, 600)) #panel = wx.Panel(self) panel = wx.PyScrolledWindow(self, -1) panel.SetBackgroundColour('white') logofile = pwd + "logo.png" logopng = scale(logofile, 120, 90) wx.StaticBitmap(panel, -1, logopng, (40, 10), (logopng.GetWidth(), logopng.GetHeight())) fotofile = pwd + "data/images/img_" + replace(title) + ".jpg" fotopng = scale(fotofile, 200, 200) h = fotopng.GetHeight() wx.StaticBitmap(panel, -1, fotopng, (20, 110), (fotopng.GetWidth(), h)) lista = wx.StaticText(panel, -1, 'Lista składników:', (45, 130 + h), style=wx.ALIGN_CENTRE) lista.SetForegroundColour((0, 0, 0)) csvfile = open(os.path.join("data", "data.csv"), 'r') reader = csv.DictReader(csvfile, delimiter='|') for row in reader: if row['name'] == title: ingred = row['ingredients'] recipe = row['recipe'] csvfile.close() line = 0 for ing in ingred.split("\n"): line = line + 1 if len(ing) > 25: line = line + 1 h_ing = line * 10 ingred = wx.StaticText(panel, -1, ingred, (20, 160 + h), style=wx.ALIGN_LEFT) ingred.SetForegroundColour((0, 0, 0)) ingred.Wrap(170) text = wx.StaticText(panel, -1, title, (230, 70), (500, 40), style=wx.ALIGN_CENTER) text.SetForegroundColour((0, 0, 0)) text.Wrap(250) font = wx.Font(14, wx.NORMAL, wx.NORMAL, wx.NORMAL) text.SetFont(font) text = wx.StaticText(panel, -1, 'Wykonanie:', (240, 130), style=wx.ALIGN_LEFT) text.SetForegroundColour((0, 0, 0)) font = wx.Font(11, wx.NORMAL, wx.NORMAL, wx.NORMAL) text.SetFont(font) self.ulub = wx.StaticText(panel, -1, 'Dodano do ulubionych!', (440, 40), style=wx.ALIGN_RIGHT) self.ulub.SetForegroundColour((10, 150, 10)) self.ulub.Hide() line1 = 0 for rec in recipe.split("\n"): line1 = line1 + 1 if len(rec) > 50: line1 = line1 + 1 h_rec = line1 * 15 recipe = wx.StaticText(panel, -1, recipe, (240, 160), style=wx.ALIGN_LEFT) recipe.SetForegroundColour((0, 0, 0)) recipe.Wrap(350) button1 = wx.Button(panel, -1, "Wstecz", (350, 5)) button1.SetBackgroundColour((50, 50, 50)) button1.SetForegroundColour('white') button1.Bind(wx.EVT_BUTTON, lambda event: Back(parent)) button2 = wx.Button(panel, -1, "Dodaj do ulubionych", (440, 5)) button2.SetBackgroundColour((50, 50, 50)) button2.SetForegroundColour('white') button2.Bind(wx.EVT_BUTTON, lambda event: self.Favorite(title)) if h_ing > 440 - h or h_rec > 480: y = 150 + h_rec panel.SetScrollbars(0, 50, 0, y / 50 + 1) panel.SetScrollRate(1, 1)
def CreatePanel(self): self.panel = wx.PyScrolledWindow(self.frame, pos = (0,0), style = wx.STAY_ON_TOP)
def __init__(self, redirect=False, filename=None): wx.App.__init__(self, redirect, filename) self.frame = wx.Frame(None, -1, title='Simple image viewer', size=(500, 500), pos=(0, 0)) #self.panel = wx.Panel(self.frame) self.panel = wx.PyScrolledWindow(self.frame, pos=(0, 0)) menubar = wx.MenuBar() menu_File = wx.Menu() menu_File.Append(wx.ID_OPEN, '&Open', 'Click here to load image') menu_File.Append(wx.ID_EXIT, 'E&xit', 'Click here to terminate application') menu_Help = wx.Menu() menu_Help.Append(wx.ID_ABOUT, '&About Simple image viewer', 'Click here to learn more about this application') menu_Help.Append(110, '&Credit', 'Creditation') menu_Tool = wx.Menu() menu_Tool.Append(ID_CONVERT_TO_GREYSCALE, 'Convert to &greyscale', 'Convert image to greyscale') menu_Tool.Append(ID_CONVERT_TO_NEGATIVE, 'Convert to &negative', 'Convert to negative') menubar.Append(menu_File, '&File') menubar.Append(menu_Tool, '&Tool') menubar.Append(menu_Help, '&Help') self.frame.SetMenuBar(menubar) self.frame.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN) self.frame.Bind(wx.EVT_MENU, self.OnClickExit, id=wx.ID_EXIT) self.frame.Bind(wx.EVT_MENU, self.OnAbout, id=wx.ID_ABOUT) self.frame.Bind(wx.EVT_MENU, self.OnCredit, id=ID_CREDIT) self.frame.Bind(wx.EVT_MENU, self.ConvertToGreyscale, id=ID_CONVERT_TO_GREYSCALE) self.frame.Bind(wx.EVT_MENU, self.ConvertToNegative, id=ID_CONVERT_TO_NEGATIVE) self.hBox = wx.BoxSizer() self.vBox = wx.BoxSizer(wx.VERTICAL) self.vBox.Add(self.hBox, proportion=1, flag=wx.EXPAND, border=0) self.imagePath = DEF_IMAGE tmpImg = wx.Image(self.imagePath, wx.BITMAP_TYPE_ANY) self.frame.SetClientSize(tmpImg.GetSize()) self.imageBox = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(tmpImg)) self.hBox.Add(self.imageBox, proportion=1, flag=wx.EXPAND, border=0) #wx.EVT_MOTION(self. # Default parameters self.configuration() self.image = tmpImg self.frame2 = '' self.status = self.frame.CreateStatusBar() self.savePath = "" self.newImage = "" self.status.SetStatusText( str(tmpImg.GetWidth()) + "x" + str(tmpImg.GetHeight())) self.frame.SetTitle(self.appname + " - " + self.imagePath) self.panel.Layout() self.frame.Show()