1

I'm working on a Selenium bot using Python.

What I want

When the user runs the python script, a console shows up and asks questions to configure the bot, like:

How many posts do you want? (1-10)
How many users do you want? (1-10)
etc.

After receiving all the answers from the user, it will say something like:

A'ight, we're go for the process!

and does its job.

Question

How can I do something like this, any ideas?

Thanks for your help.

hc_dev
  • 8,389
  • 1
  • 26
  • 38
  • if you start cody in console then you could use standard `input()`. if you don't start in console then you may have to build GUI with `tkinter`, `PyQt`, etc. Some of them may have already `dialog box` to ask one thing - and then you have to open next box for next thing. – furas May 01 '21 at 09:53
  • [15.8. Tkinter Standard Dialog Boxes](https://runestone.academy/runestone/books/published/thinkcspy/GUIandEventDrivenProgramming/02_standard_dialog_boxes.html) – furas May 01 '21 at 10:05

1 Answers1

0

If you start cody in console then you could use standard input() and `print().

answer1 = input("How many posts do you want? (1-10)")
answer2 = input("How many users do you want? (1-10)")

print("A'ight, we're go for the process!")

If you don't start in console then you may have to build GUI with tkinter, PyQt, etc. All of them should have dialog boxes to ask one thing. And then you have to use it many times for many questions.

Based on examples from 15.8. Tkinter Standard Dialog Boxes

import tkinter as tk
from tkinter import simpledialog
from tkinter import messagebox

main_window = tk.Tk()
main_window.root.withdraw()  # hide main window

answer1 = simpledialog.askinteger("Input", "How many posts do you want? (1-10)",
                                  parent=main_window, minvalue=1, maxvalue=10)

answer2 = simpledialog.askinteger("Input", "How many users do you want? (1-10)",
                                  parent=main_window, minvalue=1, maxvalue=10)

messagebox.showinfo("Info", "A'ight, we're go for the process!")

main_window.destroy()
furas
  • 134,197
  • 12
  • 106
  • 148