I want to create a floating text (does not scroll even if the canvas below scrolls) in tkinter. I tried searching for floating labels but could not find.
Right now the parent of the canvas is a frame which is scrollable.
Added another canvas on top of that canvas with the same parent frame and lifted it up by
tk.Misc.lift(floating_canvas)
Now the below canvas is scrolabble while the above one is static
Related
I made a preview dialog containing fabric.js canvas. It can be opened by clicking on "Preview" button for each item in a list. Each item in a list is associated with function which draws preview on this canvas. The preview canvas has width/height 90% of the browser screen. Is this a way to center this drawing on the fabric.js canvas (both horizontally and vertically)? Also is there a way to scale it so that it fits within canvas no matter what display size user has? The sizes of drawings are known. But I can't find how I can get canvas width/height from fabric.js and in what measures.
Tried to find the answer in fabric.js docs. I need to get fabric.js canvas width and height.
I use ggez and would like to resize the window. The only way I found is
graphics::set_drawable_size(&mut ctx, width, height);
However, when I use it, the white circle I drawn turns into a white ellipse, and a seemingly grey circle appears below. So is there another way of resizing window, one that doesn't distort what is drawn ?
use
graphics::set_screen_coordinates(ctx,rect)
right after declaring changing size with graphics::set_mode(ctx,windowmode) turns the ellipse back into a circle. The gray shape vanishes after reducing the window (this is a pretty obscure thing).
Is there a way to get buttons in Tkinter that are a different shape than rectangle?
All widgets in tkinter have a rectangular shape. So for example a "real" triangular widget is not possible.
But you could simulate one in two basic ways.
Use a Label with an image on it, as in this answer.
Using a Canvas widget as in this question.
I'm making an emacs-esque toy text editor. At startup, there's one large window (a QTextEdit derivative) in the top center of the screen, with a minibuffer (QLineEdit derivative) underneath. Both of the actual editing widgets are contained in the grids of parent classes called Window and MiniWindow (Window also keeps track of a QLabel that appears directly beneath the QTextEdit).
My Window object is at location 1, 1 in the grid, and my MiniWindow object is at 2, 1. I've set content margins to 0 and spacing to 0, which looks great at first, but when I try to grow the window by dragging on the corner, this starts to happen:
As you can see, the screen is divided into two rows (as it should be), but half of the vertical length of the screen is dedicated to each row. What I need is for the top Window to stretch its length during resizing so that it is always adjacent to the MiniWindow underneath. Is there some other option I need to be setting?
Nevermind, got it.
I was having this problem because the QLineEdit object was in the grid of my container class, MiniWindow. The height of a MiniWindow object is free to vary with the window resizing in a way that a QLineEdit alone would not be. The fix was set to the maximumHeight of MiniWindow to approximately the height of a QLineEdit, which is around 16.
Works great now.
I am trying to display mouse position on timer. I use winfo_pointerxy(), here is part of the code from my_func():
curr_x, curr_y = mouseFrame.winfo_pointerxy()
curr_x = mouseFrame.canvasx(curr_x)
curr_y = mouseFrame.canvasy(curr_y)
mouseFrame.create_oval(curr_x, curr_y, curr_x + 5, curr_y + 5, fill='green')
start_btn.after(time_interval, my_func)
It seems like I use canvasx() wrong cause it still returns position counted from the left-up corner of the screen.
According to this tkinter reference (which I use constantly)
Because the canvas may be larger than the window, and equipped with
scrollbars to move the overall canvas around in the window, there are
two coordinate systems for each canvas:
The window coordinates of a point are relative to the top left
corner of the area on the display where the canvas appears.
The canvas coordinates of a point are relative to the top left
corner of the total canvas.
If your canvas is against the upper left corner of the window (display) and you have not scrolled the canvas, the two sets of coordinates should be the same.