Photo=PhotoImage(file='./gifs/guido.gif')Ĭanvas.create_image(250, 0, image=photo, anchor=NW) # embed a photo For now, let's jump right into an example that illustrates the basics. You can get down to the pixel-by-pixel level in a canvas, but you can also deal in terms of larger objects like shapes, photos, and embedded widgets.Ĭanvases are ubiquitous in much nontrivial GUI work, and we'll see larger canvas examples show up later in this book under the names PyDraw, PyView, P圜lock, and PyTree. The canvas is based on a structured graphic object model: everything drawn on a canvas can be processed as an object. It's a place to draw shapes, move objects dynamically, and place other kinds of widgets. S = "Last point clicked at x=%s y=%s" % (x, y)ġ) don't start a variable name with a capital letter, use those for class namesĢ) avoid variable names like i1, l, l1 and the likeģ) try to keep the tkinter name space with 'tk.'Īs your program gets larger, you and others will appreciate this.When it comes to graphics, the Tkinter Canvas widget is the most free-form device in the library. StartYInput = tk.Entry(plotRow, width=10)Ĭanvas = tk.Canvas(self._root, bg='white')Ĭid(column=0, row=1, sticky='nwes') StartXInput = tk.Entry(plotRow, width=10)ĭ1 = tk.Label(plotRow, text=' Start Y: ') PlotRow = tk.Frame(root, relief='sunken')Ī = tk.Label(plotRow, text='Plot Settings ') H1 = tk.Label(functionRow, text=' Function Colour: ')įunctionColourInput = tk.Entry(functionRow, width=20)ī1 = tk.Button(functionRow, text='Select', padx=5, G1 = tk.Label(functionRow, text='Function in X: ')įunctionInXInput = tk.Entry(functionRow, width=35) # PlottingProgram101.pyįunctionRow = tk.Frame(root, relief='sunken') I would suggest to put the mouse info into the title bar of the root window. However, opening a potentially endless amount of windows is terribly resource demanding. Thanks and I hope to contribute in this site more in the future! I1 = Button(FunctionRow, text='Select', padx = 5, command = CreateFunction())Ī = Label(PlotRow, text='Plot Settings ')Ĭid(column=0, row=1, sticky=(N, W, E, S))Īlso could anyone tell me how to find current coordinates of mouse? Right now its if it enters the canvas. H1 = Label(FunctionRow, text=' Function Colour: ')įunctionColourInput = Entry(FunctionRow, width=20) G1 = Label(FunctionRow, text='Function in X: ')įunctionInXInput = Entry(FunctionRow, width=35) Self._CurrentCoordLabel = Label(CoordRow) Whenever the label changes, instead of it staying in the top, a new window opens up with the details. I am learning classes at uni so I need to learn how to use it. In the top a label will show the current position of the mouse in the canvas and the position of the last click in the canvas. I am trying to create a GUI for plotting function using Tkinter and Python. Hello, sorry for the rudeness for asking for help on the first post but I'm still a beginner in programming.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |