Sorry! Du hast recht es funktioniert auch mit:
Code: Alles auswählen
self.canvas = tk.Canvas(self,**{'height': '400', 'bg': '#4682b4', 'width': '400', 'scrollregion': '0 0 1000 1000', 'highlightthickness': '0'})
Code: Alles auswählen
self.canvas = tk.Canvas(self,**{'height': '400', 'bg': '#4682b4', 'width': '400', 'scrollregion': '0 0 1000 1000', 'highlightthickness': '0'})
Code: Alles auswählen
import tkinter as tk
#import DynTkExtend as ext
class Application(tk.Tk):
def __init__(self,**kwargs):
tk.Tk.__init__(self,**kwargs)
self.title('GuiDesigner supported design')
self.main_frame = MainFrame(self)
self.main_frame.pack(**{'fill': 'both', 'expand': 1})
class MainFrame(tk.Frame):
def __init__(self,master,**kwargs):
tk.Frame.__init__(self,master,**kwargs)
self.bottom_frame = BottomFrame(self)
self.top_frame = TopFrame(self)
self.top_frame.pack(**{'fill': 'both'})
self.bottom_frame.pack(**{'fill': 'x'})
# code added here ===========================================
canvas = self.top_frame.canvas
yscrollbar = self.top_frame.yscrollbar
xscrollbar = self.bottom_frame.xscrollbar
canvas.config(xscrollcommand=xscrollbar.set,yscrollcommand=yscrollbar.set)
xscrollbar.config(command=canvas.xview)
yscrollbar.config(command=canvas.yview)
canvas.create_line(0, 0, 1000, 1000, fill='yellow', width=2, arrowshape=(20,21,5),arrow='both')
class BottomFrame(tk.Frame):
def __init__(self,master,**kwargs):
tk.Frame.__init__(self,master,**kwargs)
self.corner_frame = tk.Frame(self,**{'height': '11', 'width': '11'})
self.xscrollbar = tk.Scrollbar(self,**{'elementborderwidth': '1', 'bd': '0', 'orient': 'horizontal'})
self.xscrollbar.pack(**{'fill': 'x', 'side': 'left', 'expand': 1})
self.corner_frame.pack(**{'fill': 'both', 'side': 'left'})
class TopFrame(tk.Frame):
def __init__(self,master,**kwargs):
tk.Frame.__init__(self,master,**kwargs)
self.canvas = tk.Canvas(self,**{'height': '400', 'bg': '#4682b4', 'width': '400', 'scrollregion': '0 0 1000 1000', 'highlightthickness': '0'})
self.yscrollbar = tk.Scrollbar(self,**{'elementborderwidth': '1', 'bd': '0'})
self.canvas.pack(**{'side': 'left'})
self.yscrollbar.pack(**{'fill': 'y', 'side': 'left'})
Application().mainloop()
Huch, gerade habe ich schon was dazu geschrieben. Ist wohl nicht sonderlich intuitivwuf hat geschrieben:Der tag [Codebox]Dein Code[/Codebox] scheint bei mir nicht zu funktionien. Vielleicht kannst du oder ein Moderator mir hierfür einen Tipp geben.
Code: Alles auswählen
import DynTkInter as tk
root = tk.Tk()
# don't do an import here, because in future it could be a XML-File
tk.load_script('scrollable_canvas_03.gui')
main_frame = tk.widget(root,'main_frame')
top_frame = tk.widget(main_frame,'top_frame')
bottom_frame = tk.widget(main_frame,'bottom_frame')
canvas = tk.widget(top_frame,'canvas')
yscrollbar = tk.widget(top_frame,'yscrollbar')
xscrollbar = tk.widget(bottom_frame,'xscrollbar')
canvas.config(xscrollcommand=xscrollbar.set,yscrollcommand=yscrollbar.set)
xscrollbar.config(command=canvas.xview)
yscrollbar.config(command=canvas.yview)
canvas.create_line(0, 0, 1000, 1000, fill='yellow', width=2, arrowshape=(20,21,5),arrow='both')
root.mainloop()
Code: Alles auswählen
import DynTkInter as tk
tk.Tk().mainloop('scroll.py')
Code: Alles auswählen
config(**{'title': 'GuiDesigner supported design'})
Frame('main_frame')
goIn()
Frame('bottom_frame')
goIn()
Frame('corner_frame',**{'height': 11, 'width': 11})
Scrollbar('xscrollbar',**{'bd': '0', 'elementborderwidth': '1', 'orient': 'horizontal'})
widget('xscrollbar').pack(**{'side': 'left', 'expand': '1', 'fill': 'x'})
widget('corner_frame').pack(**{'side': 'left', 'fill': 'both'})
goOut()
Frame('top_frame')
goIn()
Canvas('canvas',**{'highlightthickness': '0', 'height': '400', 'scrollregion': ('0', '0', '1000', '1000'), 'width': '400', 'bg': '#4682b4'})
Scrollbar('yscrollbar',**{'bd': '0', 'elementborderwidth': '1'})
widget('canvas').pack(**{'side': 'left'})
widget('yscrollbar').pack(**{'side': 'left', 'fill': 'y'})
goOut()
widget('top_frame').pack(**{'fill': 'both'})
widget('bottom_frame').pack(**{'fill': 'x'})
### CODE ===================================================
canvas = widget('.','top_frame','canvas')
yscrollbar = widget('.','top_frame','yscrollbar')
xscrollbar = widget('.','bottom_frame','xscrollbar')
canvas.config(xscrollcommand=xscrollbar.set,yscrollcommand=yscrollbar.set)
xscrollbar.config(command=canvas.xview)
yscrollbar.config(command=canvas.yview)
canvas.create_line(0, 0, 1000, 1000, fill='yellow', width=2, arrowshape=(20,21,5),arrow='both')
### ========================================================
goOut()
widget('main_frame').pack(**{'expand': '1', 'fill': 'both'})