Add an option list to a toast notification Python - python

I'm trying to get a notification in Python where I can add some options and then save whatever the user has selected.
It would be something like this:
I tried win10toast, player, and now I'm using winotify.
None of them have this function. The closest one would be Winotify, where I can add buttons which can be used as "options". The thing is that it has a limit of 5 buttons, so if I eventually have more than 5 options, I couldn't go that way.
I've been looking for a while, but I couldn't find anything like this. Is there a workaround to get a similar result?
I'd appreciate any help. Thanks in advance!

Related

How to create a new window when there's a TypeError?

I'm trying to display an error message whenever it happens. So in tkinter I want tkinter to open a new window that contains an error dialogue or something like "You are trying to extract more units than there's inside the store your record has been ignored." so whenever there's a TypeError.
The program is a data entry GUI and I want the program to warn the user that he's doing a mistake. I want and intend to ignore it as a developer but I need the user to see it.
I've searched for it a lot but I can't seem to find a working solution
I imagine it's something like
try:
do nothing #Continue running code like nothing happened or in other words, ignore the whole try statement
except TypeError:
create a new window
The cause of this error I know to be the user trying to extract 5 units out of the data base while there's only 4 of that type. Then it returns a TypeError.
How is it done ? I know it's possible and I've searched a lot but I'm just a beginner and I couldn't understand most available solutions so please simplify your solution.
Thanks a lot.

GUI: passing arguments to a function when pressing button

my excuses if that question is very simple. I have a GUI with a few pushbuttons (QT with PySide). I want to connect 2 buttons with one function which is supposed to do the same thing with one difference. For that I need to pass an argument. Here is the type of code:
def test(flag):
if flag:
do something
else:
do something else
# button calls:
self.ui.button1.clicked.connect(test(True))
self.ui.button2.clicked.connect(test(False))
I have tried things as above, but it does not like the test(True). I have also played with lambda's and I am getting stuck at the same spot. So far I have been calling two separate functions, but that is not a good practice. Any help is appreciated.
Thanks
It works! Much simpler than I thought. Many thanks.
You said you used lambdas, did you try this
self.ui.button1.clicked.connect(lambda:test(True))
self.ui.button2.clicked.connect(lambda:test(False))
This should work.

How to take user input in matplotlib?

Is there any way of getting some input from a user in matplotlib? For example, a drop down list or a text box? What alternatives are there?
If there isn't anything, what would be the easiest way of displaying data based on what a user's input would be?
This could be a very very WIDESPREAD answer...
What exactly do you mean when you say "input from user?"
if you are just talking about a textbox and an okay button then
raw_input('Enter your text')
If you're wanting something a bit more sophisticated and controllable I suggest looking into the Tkinter tools and creating your own GUI where you can create things like combo boxes, checkboxes, entry widgets, popup boxes, and a lot more.
if this doesn't exactly answer what you are asking please post an example of your code then add something like
code code code
#HERE YOU WOULD PUT WHAT YOU WANT TO ACCOMPLISH
code code code

event handling iron python

If there are lets say 4 buttons, all with the same Click event, how can I find out which button was pressed?
if the event looks like this def Button_Click(self, sender, e): I'm sure I can compare sender to my buttons somehow. But how?
Well, I've never used IronPython so I don't know how much help this will be, but what I usually do when trying to figure out these things in regular python is to print type(sender) , print sender and print dir(sender) to console(or output to a file if you don't have a console available).
This should help you figure out what exactly is the "sender" parameter. In the simplest case it could be the button itself so a simple == will work to know which button it was. Or it could have a method/property that gets you the button object. In which case, dir(sender) might contain an obvious one, or if not, google the class name gotten from type(sender) and see if you can find any docs.

Make Spinctrl selected when activated in WxPython

I have 4 spinctrls in my app. When I click on them, I want all their
content to be selected instantly. And another thing is, I need to make
them tab traversal. Can you help me with some sort of code to do this
task?
Thanks in advance.
You need to catch EVT_SPIN or EVT_SPINCTRL and in your handler, you can select all the values by calling each of the control's GetValue method. In the wxPython demo, it seems to support tab traversal. I'm not sure what's going on with yours. Did you try the FloatSpin widget as an alternative?

Categories