Displaying dropdown choice in the dropdown box using python tkinter - python

I'm making an airplane booking programme using python. I want to know how to create a dropdown list with options using tkinter module and how to store the option the user selects.
for example, if a user chooses "Manila" from the dropdown list of destinations, "Manila" will be shown on the drop box and will be stored in the programme(for the purpose of displaying tickets). I also don't want my dropdown list box be opened in another window.
I am at a very elementary stage right now since this is a JC project so I would appreciate it if the solutions to my problem could be explained in simpler terms.
Thank you!

Related

Add multiple Elements into every entry in Drop-Down Menu Tkinter

I am trying to make a drop-down menu which supports an image on the left side, then two labels on top of each other, these also need to be different sized, and then on the initial button to open the menu, a down arrow on the right side.
For reference purposes, I am trying to clone the Outlook drop-down option in the Info Frame
Tkinter menus don't support that. You will have to create your own dropdown window and then managing all of the bindings for making it appear and disappear.

Selenium Python not able to select value from drop down for Amazon product detail screen

I'm trying to automate an add to cart operation for amazon products, one issue I ran into is I was not able to simulate click dropdown menu using selenium in python. Here is my current code (ignore imports) :
select = Select(self.driver.find_element_by_id("native_dropdown_selected_size_name"))
print("select = ", select)
for o in select.options:
if o.text == '12':
print("found")
select.select_by_visible_text("12")
In my code, I'm trying to select the size 12 option from menu dropdown. From the print statement I can tell the dropdown is found and size 12 is also there but the select_by_visible_text doesn't seem to work.
Another option I have tried is:
self.driver.find_element_by_xpath("//select[#id='native_dropdown_selected_size_name']/option[text()='12']").click()
which also doesn't seem to work.
Here is the product I'm experimenting on: https://www.amazon.com/dp/B07KRY1JPK. The color option is there by default so the issue is with the size selection.
Any help is appreciated. Thanks in advance!
Update:
I'm able to solve the issue by clicking on the span tag (sibling after the select) and the a tag that is hidden under span to make a selection. The original select tag does not work for some reason. My guess is it is for native only.
The options text contains space, use normalize-space:
driver.find_element_by_xpath("//select[#id='native_dropdown_selected_size_name']/option[normalize-space(text())='12']").click()

Inputs inside multiple forms with no submit button need to be displayed

I'm new here and I'm not at a high programming level...
I have a problem with the developing of a web application using flask and html. In the same html page I have some input boxes (that will be compiled by a user) and their content would be inserted inside a select that initially is empty. In addition I have no submit button and I could not insert it in my app because of the will of my boss. Is there a way to do this?
I've tried searching through the web for hours, but still nothing... Is there someone that could help me?
Add onblur function to input box and write function to insert their content. You can use onfocusout function also.

While in runtime, is it possible add an sub-menu item to the tkinter dropdown menu?

While in runtime (I mean, while the user operates the application), I would like to know if is it possible, usind Tkinter, add an sub-menu item to an existing menu, and link the new sub-menu to some code.

Equivalent of an HTML multiple SELECT box in wxPython

I'd like to create a ListBox in wxPython with the same semantics as a multiple select box in HTML. Specifically I'd like the following semantics
When the user clicks on an entry in the list, all other entries become de-selected and the clicked entry becomes selected. If the entry was already selected then it stays selected.
When the user holds down the Ctrl key while clicking on an entry, all other entries stay unchanged, but it toggles whether the clicked entry is selected.
When the user holds down shift and clicks on an entry, that entry and every entry between it and the last clicked entry become selected.
In Java I get this by using the JList class in Swing and setting the selection mode to MULTIPLE_INTERVAL_SELECTED. I assume that there's a way to do this with the wxPython toolkit, but I can't figure out how to get a ListBox or ListCtrl or any other class to do this short of doing an enormous amount of event-driven programming myself.
I think what you're looking for is the wxLB_EXTENDED list box style. Specify style = wx.LB_EXTENDED when you create the ListBox.
You can then use the GetSelections method to obtain a list of the selected items.

Categories

Resources