8

I'm just playing around with tkinter in python a little, but have some "troubles" with my i3 (tiling) windowmanager.

I want to create a floating window for entering a value (similar to a "Open File" Dialog). This has to be possible, since Gimp for example works with floating windows in i3, too. Of course I'm not sure if it's possible with tkinter.

Does someone happen to know the problem and found the solution? I guess there's got to be some sort of flag to set on the tkinter.Tk() widget.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
J. Doe
  • 326
  • 2
  • 12

2 Answers2

16

You can tell i3wm that this is a dialog by setting your root element's type attribute to dialog

from Tkinter import Tk
root = Tk()
root.attributes('-type', 'dialog')
root.mainloop()

i3 will open the window automatically in floating mode instead of tiling.

Dane Johnson
  • 314
  • 3
  • 11
  • 1
    This sets the Extended Window Manager Hints (https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#idm140130317606816) for the Tk window to let the manager know the type of window. Also used for menus and splash-screens. – patthoyts Mar 11 '18 at 12:34
3

If you know the title of the window, or any pattern of the title, you can add the following line in your i3 config file to make it float on start:

for_window [title="title of your window"] floating enable

For example, I use this config to make my gnome-keyring floating every time it asks me for password:

for_window [title="Unlock private key"] floating enable

EDIT:

According to this https://faq.i3wm.org/question/61/forcing-windows-as-always-floating.1.html:

"i3 sets dialog, utility, toolbar and splash windows to floating."

Mingwei Zhang
  • 663
  • 7
  • 15
  • Not yet exactly what I am looking for, but thanks. Guess that solves it for the moment. – J. Doe Mar 08 '16 at 11:53
  • @J.Doe Sorry for my mistake. I think in order to make i3 automatically recognize it as floating, you needs to set the window type as "dialog, utility, or splash window". I've added the reference in the answer. I am not familiar with Tkinter though. Have you tried creating some basic dialog boxes in i3? – Mingwei Zhang Mar 09 '16 at 19:16