def _get_media(self): # All the forms on a FormSet are the same, so you only need to # interrogate the first form for media. if self.forms: return self.forms[0].media else: return Media()
def _get_media(self): """ Provide a description of all media required to render the widgets on this form """ media = Media() for field in self.fields.values(): media = media + field.widget.media return media
def __init__(self, master, command = None): super().__init__(master) self.command = command self.focus_set() self.bind('<Left>', self.previous) self.bind('<Up>', self.restore) self.bind('<Down>', self.delete) self.bind('<Right>', self.next) oframe = tkinter.LabelFrame(self, text = 'Trash') oframe.pack() iframe = tkinter.Frame(oframe) iframe.pack(expand = True, fill = tkinter.X) self._previousButton = tkinter.Button(iframe, text = 'Previous (Left)', command = self.previous) self._previousButton.pack(expand = True, fill = tkinter.X, side = tkinter.LEFT) self._nextButton = tkinter.Button(iframe, text = 'Next (Right)', command = self.next) self._nextButton.pack(expand = True, fill = tkinter.X, side = tkinter.LEFT) tkinter.Button(iframe, text = 'Restore (Up)', command = self.restore).pack(expand = True, fill = tkinter.X, side = tkinter.LEFT) tkinter.Button(iframe, text = 'Delete (Down)', command = self.delete).pack(expand = True, fill = tkinter.X, side = tkinter.LEFT) tkinter.Button(iframe, text = 'Delete All', command = self.clear).pack(expand = True, fill = tkinter.X, side = tkinter.LEFT) frame = self._imageFrame = tkinter.LabelFrame(oframe) frame.pack() tkinter.Label(frame, text = 'Size:').grid(row = 0, column = 0, sticky = 'e') tkinter.Label(frame, text = 'Filesize:').grid(row = 1, column = 0, sticky = 'e') self._sizeLabel = tkinter.Label(frame) self._sizeLabel.grid(row = 0, column = 1, sticky = 'w') self._fileSizeLabel = tkinter.Label(frame) self._fileSizeLabel.grid(row = 1, column = 1, sticky = 'w') mediaFrame = self._mediaFrame = Media.Frame(frame, onFrameChange = lambda mframe, thumbnail: Media.Frame.thumbnailScreensize(self, mframe._image)) mediaFrame.bind('<Button-1>', lambda e: mediaFrame.osOpen()) mediaFrame.grid(row = 2, column = 0, columnspan = 2, sticky = 'ew') self._dict = Data._dict self._getGenerator() item = next(self._itemsGenerator, None) if item: self._items = [item] else: self._items = [] self._showIndex()
def _createFrame(self, frame, file, extern=False): lframe = tkinter.LabelFrame(frame) lframe.columnconfigure(0, minsize=self.thumbnailSize + 10) lframe.rowconfigure(0, minsize=self.thumbnailSize + 10) lframe.grid() mframe = Media.Frame(lframe, file, (self.thumbnailSize, self.thumbnailSize), onFrameChange=self._onFrameChange) mframe._var = tkinter.BooleanVar() mframe._file = pathlib.Path(file) mframe._extern = extern mframe.grid() mframe.bind('<Button-1>', self._openFile(mframe)) mframe.bind('<Enter>', self._onEnterImage(mframe)) if mframe.isVideo: mframe.bind('<Button-3>', self._popup(mframe)) return 1 return 0
def __init__(self, master, command=None, browse=None): super().__init__(master) self.command = command or self._browse self.browse = browse self._snao = pysaucenao.SauceNao(api_key=Setting.Data.apiKey) self._tempDir = pathlib.Path(Setting.Data.tempDir).resolve() self._destDir = pathlib.Path(Setting.Data.destDir).resolve() self._event_loop = asyncio.new_event_loop() oframe = tkinter.LabelFrame(self, text='SauceNAO') oframe.pack() frame = self._buttonsFrame = tkinter.Frame(oframe) self._previousButton = tkinter.Button(frame, text='Previous (Left)', command=self._previous) self._previousButton.pack(expand=True, fill=tkinter.X, side=tkinter.LEFT) self._nextButton = tkinter.Button(frame, text='Next (Right)', command=self._next) self._nextButton.pack(expand=True, fill=tkinter.X, side=tkinter.LEFT) self._checkButton = tkinter.Button(frame, text='Check (Up)', command=self._check) self._checkButton.pack(expand=True, fill=tkinter.X, side=tkinter.LEFT) self._deleteButton = tkinter.Button(frame, text='Delete (Down)', command=self._delete) self._deleteButton.pack(expand=True, fill=tkinter.X, side=tkinter.LEFT) self._checkAllButton = tkinter.Button(frame, text='Check all', command=self._checkAll) self._checkAllButton.pack(expand=True, fill=tkinter.X, side=tkinter.LEFT) self._imageFrame = tkinter.LabelFrame(oframe) self._imageFrame.pack() mediaFrame = self._mediaFrame = Media.Frame( self._imageFrame, onFrameChange=lambda mframe, thumbnail: Media.Frame. thumbnailScreensize(self, mframe._image)) mediaFrame.pack() self._messageLabel = tkinter.Label(oframe) self._messageLabel.pack() self._dict = Data._dict self._getGenerator() item = next(self._itemsGenerator, None) if item: self._items = [item] else: self._items = [] if browse: self._browse() else: self._checkAll()
canvas.config(width=width, height=height, scrollregion=(0, 0, width, height)) # increase inner frame if content size is bigger than canvas canvas.itemconfig(window, width=max(width, oframe.winfo_width()), height=max(height, oframe.winfo_height())) self.bind('<Configure>', configure) # set class pack managers to outer frame managers self.grid = oframe.grid self.pack = oframe.pack self.place = oframe.place # fix destroy destroy = self.destroy # destroy itself first otherwise this will result in an infinite loop because oframe.destroy would call self.destroy self.destroy = lambda: (destroy(), oframe.destroy()) if __name__ == '__main__': import widgets.Media as Media import widgets.Select as Select root = tkinter.Tk() frame = Frame(root) frame.pack(fill=tkinter.BOTH) Media.Frame(frame, next(next(iter(Select.Data))[1]), thumbSize=None).pack() root.mainloop()