You are not logged in.

#1 2020-01-02 12:59:32

Yann
Member
Registered: 2017-11-23
Posts: 172

[SOLVED] create a floating window with clickable buttons

Hi everyone,
I use archlinux with i3wm and I would like to create, when I click on a i3block, a floating window (popup) with clickable buttons that perform actions.
I can not find any program supplying this capacity.
Could you recommend me some please?
Thanks for your time.

Last edited by Yann (2020-01-09 20:30:42)


all different - all equal

Offline

#2 2020-01-02 13:05:36

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,631
Website

Re: [SOLVED] create a floating window with clickable buttons

I'm not sure I follow.  You want to create a program, but you can't find a program providing ... something.

This would be very easy to write even just with X11, or you could use a toolkit like GTK.

If you want to hijack an existing tool, you could try something like this with tint2, though that example is now probably useless as the config options have changed quite a bit in seven years.

If you are okay with the "buttons" being text menu items, you could use nearly any one of countless menu programs including zenity, or jgmenu.

Last edited by Trilby (2020-01-02 13:10:51)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2020-01-02 14:31:34

teckk
Member
Registered: 2013-02-21
Posts: 353

Re: [SOLVED] create a floating window with clickable buttons

There is also python. Using gobject, PyQt5, tkinter etc.

Very simple window/button example with tkinter.

#! /usr/bin/python

from tkinter import *

def donothing():
   filewin = Toplevel(root)
   button = Button(filewin, text="Do nothing button")
   button.pack()
   
root = MyWindow()
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="New", command=donothing)
filemenu.add_command(label="Open", command=donothing)
filemenu.add_command(label="Save", command=donothing)
filemenu.add_command(label="Save as...", command=donothing)
filemenu.add_command(label="Close", command=donothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="File", menu=filemenu)

editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Undo", command=donothing)
editmenu.add_separator()
editmenu.add_command(label="Cut", command=donothing)
editmenu.add_command(label="Copy", command=donothing)
editmenu.add_command(label="Paste", command=donothing)
editmenu.add_command(label="Delete", command=donothing)
editmenu.add_command(label="Select All", command=donothing)
menubar.add_cascade(label="Edit", menu=editmenu)

helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Help Index", command=donothing)
helpmenu.add_command(label="About...", command=donothing)
menubar.add_cascade(label="Help", menu=helpmenu)

root.config(menu=menubar)
root.mainloop()

Offline

#4 2020-01-02 15:00:13

seth
Member
Registered: 2012-09-03
Posts: 13,672

Re: [SOLVED] create a floating window with clickable buttons

rofi or dmenu?

You Need to be more specific with your demands.

Online

#5 2020-01-02 15:31:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,631
Website

Re: [SOLVED] create a floating window with clickable buttons

I agree, this needs to be far more specific, but wouldn't the presently available criteria already rule out dmenu and likely rofi?  Dmenu certainly doesn't have clickable buttons/items.

Last edited by Trilby (2020-01-02 16:34:18)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2020-01-02 15:36:57

seth
Member
Registered: 2012-09-03
Posts: 13,672

Re: [SOLVED] create a floating window with clickable buttons

Ahh, I've dmenu-ee installed (which, like rofi, has mouse support)

Online

#7 2020-01-02 16:45:32

Yann
Member
Registered: 2017-11-23
Posts: 172

Re: [SOLVED] create a floating window with clickable buttons

Thanks a lot for all the answers. Very helpful.

I thought being enough accurate as my request is probably very simple for you.

I use i3 with I3bar with i3blocks. I would like to be able to have a floating window popup appearing when I click on a particular i3block, I would like this window to be stuck to the i3bar at the top with particular dimensions AND, I would like to be able to click on buttons on it that will perform some actions.
For example, I would like this popup to have lots of colors and when I click on one of it I want to perform a mqtt publication to change the color of one of my iot bulbs.

I know how to do floating windows with i3, but, after lots of researches, I don't think I can do clickable floating window with i3wm program.

I tried hard with dmenu, but it can not display more than 2 different colors in the dmenu bar as I would like to be able to click on a color zone (square, rectangle).

I looked at zenity, looks great, yad looks to do very good things, probably enough, I will figure out.

Trilby wrote:

This would be very easy to write even just with X11, or you could use a toolkit like GTK

Is it that easy or overkill for the simple popup I want to do?

Hi teckk, I tried your code but got some errors, could you make it working well please, there is no import for MyWindow for example. If you do, I will give a try.

Is rofi better than dmenu?

Is dmenu-ee better in all ways of dmenu? Will I be able to do what I want with dmenu-ee?

Thanks for your time!

Last edited by Yann (2020-01-02 16:48:13)


all different - all equal

Offline

#8 2020-01-02 17:03:15

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,631
Website

Re: [SOLVED] create a floating window with clickable buttons

Wait, you just want a color selection dialog?  Then you should have said that.  Pick one:
https://www.fossmint.com/color-picking-tools-for-linux/


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2020-01-02 17:08:09

Yann
Member
Registered: 2017-11-23
Posts: 172

Re: [SOLVED] create a floating window with clickable buttons

He he. That looks exactly as what I am looking like. Didn't think that some UI tools were develop just for color selection. Going to try that ASAP.
Thanks !!


all different - all equal

Offline

#10 2020-01-02 20:36:51

seth
Member
Registered: 2012-09-03
Posts: 13,672

Re: [SOLVED] create a floating window with clickable buttons

Most of them won't print the selected color to stdout, in case of frustration: try "zenity --color-selection"

Online

#11 2020-01-03 08:31:19

Yann
Member
Registered: 2017-11-23
Posts: 172

Re: [SOLVED] create a floating window with clickable buttons

So far I only tried yad --color and I can recover the color through stdout. Will try a UI program designed for that, with a color memory, etc.

Last edited by Yann (2020-01-03 08:31:58)


all different - all equal

Offline

#12 2020-01-09 20:32:04

Yann
Member
Registered: 2017-11-23
Posts: 172

Re: [SOLVED] create a floating window with clickable buttons

I made a mix of a gtk python window with yad --color when needing a color palette.
Thanks for your time.


all different - all equal

Offline

Board footer

Powered by FluxBB