Wxpython imageviewer
It does mean your wxpython object exists and can be rendered which is at least something. MainFrame(None, title="Text from Comic Pages")įirst of all, anytime wxpython puts something in the top left it means it doesn't know where to put it, I think you have worked that out, but it is useful to know. # get the frame's top level parent and close it ImgsPath = glob.glob(os.path.join(dDlg.GetPath(), '*.jpg')) With wx.DirDialog(self, "Choose a Directory", ImgPath = glob.glob(os.path.join(fDlg.GetPath())) With wx.FileDialog(self, "Choose a File", # call onQuit if the app is closed via x in title bar (in order to do some cleaning up) # connect the quit button to the actual event of quitting the appįileMenu.Bind(wx.EVT_MENU, self.onQuit, quitBut) QuitBut = wx.MenuItem(fileMenu, wx.ID_EXIT, '&Quit', 'Exit the Programm') OpDirBut = wx.MenuItem(fileMenu, wx.ID_ANY, 'Open &Directory', 'Open Working Directory')įileMenu.Bind(wx.EVT_MENU, self.onOpenDirectory, opDirBut) # add an open directory Button to the file menu # bind the open button to the on_open_directory eventįileMenu.Bind(wx.EVT_MENU, self.onOpenFile, opFileBut) OpFileBut = wx.MenuItem(fileMenu, wx.ID_ANY, '&Open File', 'Open a Single File') Sizer.Add(rSubPan, wx.ID_ANY, wx.EXPAND|wx.ALL)
Sizer.Add(lSubPan, wx.ID_ANY, wx.EXPAND|wx.ALL) LSubPan = comicPageViewer(self, imgsPath) Sizer.Add(butSaveTxt, pos=(1, 3), flag=wx.EXPAND) Sizer.Add(butOCR, pos=(1, 2), flag=wx.EXPAND) Sizer.Add(butNext, pos=(1, 1), flag=wx.EXPAND) Sizer.Add(butPrev, pos=(1, 0), flag=wx.EXPAND) Sizer.Add(comPage, pos=(0, 0), span=(1, 4),īutPrev = wx.Button(self, label="Previous Page")īutNext = wx.Button(self, label="Next Page")īutOCR = wx.Button(self, label="Find Text/OCR")īutSaveTxt = wx.Button(self, label="Save Current Text(s)") # laying out the grid for the image panel and the ctrl-buttons Main_sizer.Add(comPageStatBoxSizer, wx.ID_ANY, wx.EXPAND|wx.ALL) # add the static box with the image box that is nested in it # create a main sizer which stretches all other sizers to the # add the image box sizer to the sizer of theĬomPageStatBoxSizer.Add(comPageBoxSizer, wx.ID_ANY, wx.EXPAND|wx.ALL)
# create another sizer for the actual image boxĬomPageBoxSizer = wx.StaticBitmap(self, wx.ID_ANY, img) # print('comicPagePanel_if-imgPath', imgsPath)ĬomPageBox = wx.Bitmap(wx.Image(imgsPath, wx.BITMAP_TYPE_ANY))
# Feeding the panel with an image when starting the program works # create the static box with the panel description.ĬomPageStatBox = wx.StaticBox(self, wx.ID_ANY, "Comic Page")ĬomPageStatBoxSizer = wx.StaticBoxSizer(comPageStatBox, wx.VERTICAL)
Sizer.Add(speeBubImg, wx.ID_ANY, flag=wx.EXPAND|wx.ALL) SpeeBubImg = wx.StaticBox(self, wx.ID_ANY, "Text Editor") I appreciate any constructive help and feedback you can give me. It also reproduces the faulty result which you can see on the screenshot.
WXPYTHON IMAGEVIEWER CODE
I also had a look at this photo viewer tutorial at Mouse vs Python, but I could't get it to work in my program.īelow is the code I have so far.
WXPYTHON IMAGEVIEWER UPDATE
However, when I try to update the panel with another image via the open file- or open directory-dialog it does not display correctly (see screenshot).įrom what I read so far about updating panels ( wxpython refresh window on button press, wxPython - change panel by button, How do you force refresh of a wx.Panel?) it is not enough to just recall the function responsible for creating the sub panel, but I seem to oversee or miss something elementary because I cannot get any of the proposed solutions to work in my code. When I feed an image to the panel at the start of the program, it shows correctly. I'm a beginner at python and programming for that matter and trying to implement a rudimentary image viewer and having trouble to update the sub panel, in which the image should be shown.