JynPopMod Python Module
Project description
Seperated to Utils!
-
switch_case(variable, cases)variable: A value to check against the dictionarycases.cases: A dictionary where keys are the possible values ofvariableand values are the corresponding functions to execute.- What it does: Mimics a switch-case statement, executing the function associated with the value of
variable.
-
pop(message)message: A string to display in a message box.- What it does: Displays a simple message in a pop-up window.
-
popinp(message)message: A string to display in an input dialog.- What it does: Prompts the user for input through a dialog box.
-
main_window()- What it does: Use it as a root like root = main_window().
-
set_window_size(width, height)width: The desired width of the window.height: The desired height of the window.- What it does: Sets the size of the window.
-
center_window(window, width, height)window: The Tkinter window object.width: The width of the window.height: The height of the window.- What it does: Centers the window on the screen.
-
minimize_window(window)window: The Tkinter window object.- What it does: Minimizes the window.
-
maximize_window(window)window: The Tkinter window object.- What it does: Maximizes the window.
-
set_window_bg_color(window, color)window: The Tkinter window object.color: A string representing the color to set as the background (e.g.,"red","blue").- What it does: Sets the background color of the window.
-
create_button(window, text, command)window: The Tkinter window object.text: The label or text to display on the button.command: The function to call when the button is clicked.- What it does: Creates a button widget.
-
create_label(window, text)window: The Tkinter window object.text: The text to display on the label.- What it does: Creates a label widget.
-
create_text_widget(window, height, width)window: The Tkinter window object.height: The height of the text widget.width: The width of the text widget.- What it does: Creates a text widget for multi-line text input.
-
bind_mouse_click(widget, callback)widget: The Tkinter widget to bind the mouse click event to.callback: The function to call when the mouse click happens.- What it does: Binds a mouse click event to a widget.
-
bind_key_press(widget, callback)widget: The Tkinter widget to bind the key press event to.callback: The function to call when a key is pressed.- What it does: Binds a key press event to a widget.
-
move_file(src, dest)src: The source file path.dest: The destination file path.- What it does: Moves a file from
srctodest.
-
copy_file(src, dest)src: The source file path.dest: The destination file path.- What it does: Copies a file from
srctodest.
-
create_directory(path)path: The directory path to create.- What it does: Creates a new directory at the specified
path.
-
create_zip_file(file_paths, zip_path)file_paths: A list of paths to files to include in the ZIP.zip_path: The path where the resulting ZIP file should be saved.- What it does: Creates a ZIP file from the specified files.
-
extract_zip_file(zip_path, dest)zip_path: The path of the ZIP file.dest: The destination directory to extract the files to.- What it does: Extracts files from the ZIP to the destination directory.
-
capture_photo(output_path)output_path: The file path where the captured photo should be saved.- What it does: Captures a photo using the webcam and saves it to
output_path.
-
record_video(output_path, duration)output_path: The file path to save the recorded video.duration: The duration in seconds for which to record the video.- What it does: Records a video using the webcam for the specified duration and saves it to
output_path.
-
start_http_server(port)port: The port on which the server should run.- What it does: Starts an HTTP server listening on the specified port.
-
get_server_status()- What it does: Checks and returns the current status of the HTTP server.
-
upload_file_to_server(file_path, url)file_path: The path of the file to upload.url: The server URL where the file should be uploaded.- What it does: Uploads a file to the server at the specified URL.
-
text_to_speech(text)text: The text to convert into speech.- What it does: Converts the
textinto speech.
-
speech_to_text()- What it does: Records speech from the microphone and converts it into text.
-
get_cpu_usage()- What it does: Retrieves the current CPU usage percentage.
-
get_memory_usage()- What it does: Retrieves the current memory usage percentage.
-
get_ip_address()- What it does: Retrieves the system's current IP address.
-
safe_run(func)func: The function to run safely.- What it does: Executes the function
func, catching any exceptions and preventing the program from crashing.
-
track_mouse_position(callback)callback: The function to call whenever the mouse position changes.- What it does: Tracks the mouse position and calls the
callbackwhen it moves.
-
run_shell_command(command)command: The shell command to execute.- What it does: Runs a system shell command and returns the result.
-
send_email(subject, body, to_email)subject: The subject of the email.body: The body content of the email.to_email: The recipient's email address.- What it does: Sends an email with the specified subject and body to the given recipient.
-
change_widget_bg_color(widget, color)widget: The Tkinter widget.color: The background color to apply to the widget.- What it does: Changes the background color of the widget.
-
change_widget_font(widget, font)widget: The Tkinter widget.font: The font to apply to the widget (e.g.,"Helvetica 12").- What it does: Changes the font of the widget.
-
add_widget_border(widget, width, color)widget: The Tkinter widget.width: The border width to apply.color: The border color to apply.- What it does: Adds a border to the widget.
-
pack_with_padding(widget, padding)widget: The Tkinter widget.padding: The padding around the widget.- What it does: Packs the widget with the specified padding.
-
grid_widget(widget, row, column)widget: The Tkinter widget.row: The row in the grid where the widget should be placed.column: The column in the grid where the widget should be placed.- What it does: Places the widget in a specific row and column in the grid.
-
place_widget(widget, x, y)widget: The Tkinter widget.x: The x-coordinate where to place the widget.y: The y-coordinate where to place the widget.- What it does: Places the widget at the specified x and y coordinates.
-
delayed_pop(message, delay)message: The message to display.delay: The number of seconds to wait before displaying the message.- What it does: Displays a delayed pop-up message after the specified delay.
-
start_timer(duration, callback)duration: The duration in seconds for the timer.callback: The function to call when the timer finishes.- What it does: Starts a timer and triggers the
callbackafter the specified duration.
-
get_weather(city, api_key)city: The name of the city for which to get the weather.api_key: The API key for accessing the weather API.- What it does: Retrieves the weather data for the specified city using an external weather API.
-
copy_to_clipboard(text)text: The text to copy to the clipboard.- What it does: Copies the given
textto the clipboard.
-
paste_from_clipboard()- What it does: Pastes the text from the clipboard.
-
text_to_speech(text)
text: The text to be converted to speech.- What it does: Converts the given
textinto speech using thepyttsx3engine.
speech_to_text()
- What it does: Records audio from the microphone and converts the spoken words to text using Google's speech recognition API.
start_timer(seconds, callback)
seconds: The number of seconds to run the timer for.callback: The function to call once every second during the timer's countdown.- What it does: Runs a countdown timer for
seconds, callingcallback()once every second.
generate_random_string(length=15)
length: The desired length of the generated string.- What it does: Generates a random alphanumeric string of length
length, with possible special characters.
find_files_by_extension(directory, extension)
directory: The directory to search in.extension: The file extension to search for (e.g.,'.txt').- What it does: Returns a list of files in
directorythat have the givenextension.
get_ip_address()
- What it does: Returns the local IP address of the machine.
send_email(subject, body, to_email, mailname, mailpass)
subject: The subject of the email.body: The body content of the email.to_email: The recipient's email address.mailname: The sender's email username.mailpass: The sender's email password.- What it does: Sends an email using Gmail's SMTP server.
convert_image_to_grayscale(image_path, output_path)
image_path: The path to the image to convert.output_path: The path to save the grayscale image.- What it does: Converts the given image to grayscale and saves it at
output_path.
play_audio(text)
text: The text to be converted to speech.- What it does: Converts the given
textto speech usingpyttsx3.
-
record_audio()- What it does: Records audio from the microphone and converts it to text using speech recognition.
-
get_cpu_usage()- What it does: Returns the current CPU usage as a percentage.
-
get_memory_usage()- What it does: Returns the current memory usage as a percentage.
-
open_url(url)url: The URL to open.- What it does: Opens the specified URL in the default web browser.
-
create_zip_file(source_dir, output_zip)source_dir: The directory containing files to zip.output_zip: The output path for the zip file.- What it does: Creates a ZIP file from the contents of the
source_dir.
-
extract_zip_file(zip_file, extract_dir)zip_file: The path to the zip file.extract_dir: The directory to extract files into.- What it does: Extracts the contents of the ZIP file to
extract_dir.
-
capture_screenshot(output_path)output_path: The path to save the screenshot.- What it does: Takes a screenshot of the current screen and saves it to
output_path.
-
move_file(source, destination)source: The file path of the source file.destination: The file path to move the file to.- What it does: Moves a file from
sourcetodestination.
-
copy_file(source, destination)source: The file path of the source file.destination: The file path to copy the file to.- What it does: Copies a file from
sourcetodestination.
-
show_file_properties(file_path)file_path: The path to the file.- What it does: Returns the file's size and last modified time.
-
check_website_status(url)url: The URL of the website to check.- What it does: Returns
Trueif the website is accessible (status code 200), elseFalse.
-
run_shell_command(command)command: The shell command to execute.- What it does: Executes a shell command and returns the output and any errors.
-
get_weather(city, api_key)city: The name of the city to check the weather for.api_key: The API key for accessing the weather service.- What it does: Retrieves the current weather for the specified city using the OpenWeatherMap API.
-
monitor_file_changes(file_path, callback)file_path: The path to the file to monitor.callback: The function to call when the file is modified.- What it does: Monitors the file for changes and calls
callback()when the file is modified.
-
reverse_string(string)string: The string to reverse.- What it does: Returns the reversed version of the input
string.
-
calculate_factorial(number)number: The number to calculate the factorial of.- What it does: Returns the factorial of
number.
-
swap_values(a, b)a: The first value.b: The second value.- What it does: Returns
bandaswapped.
-
find_maximum(numbers)numbers: A list of numbers.- What it does: Returns the maximum value in the list
numbers.
-
find_minimum(numbers)numbers: A list of numbers.- What it does: Returns the minimum value in the list
numbers.
-
get_random_choice(choices)choices: A list of choices.- What it does: Returns a random element from the list
choices.
-
generate_unique_id()- What it does: Generates and returns a unique ID using
uuid.
- What it does: Generates and returns a unique ID using
-
concatenate_lists(list1, list2)list1: The first list.list2: The second list.- What it does: Returns a new list that is the concatenation of
list1andlist2.
-
write_to_file(filename, content)filename: The file to write to.content: The content to write to the file.- What it does: Writes
contentto the specified file.
-
read_from_file(filename)filename: The file to read from.- What it does: Reads and returns the content of the specified file.
-
parse_json(json_string)json_string: The JSON string to parse.- What it does: Parses the JSON string and returns the corresponding Python object.
-
create_file_if_not_exists(filename)filename: The file to create if it doesn't exist.- What it does: Creates an empty file at
filenameif it doesn't already exist.
-
create_directory(directory)directory: The directory to create if it doesn't exist.- What it does: Creates the specified directory if it doesn't already exist.
-
send_http_request(url, method='GET', data=None)url: The URL to send the request to.method: The HTTP method to use ('GET' or 'POST').data: The data to send (only used with 'POST').- What it does: Sends an HTTP request to the specified
urlusing the specifiedmethodanddata, returning the response.
-
get_cpu_temperaturelinux()- What it does: Returns the CPU temperature (in Celsius) for Linux systems, or
Noneif not available.
- What it does: Returns the CPU temperature (in Celsius) for Linux systems, or
-
calculate_square_root(number)number: The number to calculate the square root of.- What it does: Returns the square root of
number.
-
track_mouse_position(callback)callback: The function to call with the mouse's position as arguments.- What it does: Tracks the mouse position and calls
callback()with the current(x, y)position.
-
show_error_messagebox(message)
message: The error message to display.- What it does: Displays a message box with the title "Error" and the provided message.
start_background_task(backtask)
backtask: The function to execute in the background.- What it does: Starts a separate thread to run the provided function without blocking the main program.
nocrash(func)
func: The function to wrap in a crash-preventing decorator.- What it does: Executes the function safely, preventing unhandled exceptions from crashing the program.
contains_swears_better(text)
text: The input string to check.- What it does: Returns
Trueif the text contains any profane words; otherwise,False.
filter_profanity_in_text(text)
text: The input string to filter.- What it does: Censors profanity in the provided text by replacing inappropriate words with asterisks.
speech_to_text_with_filter()
- No arguments.
- What it does: Listens for speech input, converts it to text, and filters any profanity.
get_system_uptime()
- No arguments.
- What it does: Returns the system uptime in seconds since the last boot.
download_image_from_url(image_url, save_path)
image_url: The URL of the image to download.save_path: The local path to save the image.- What it does: Downloads an image from the specified URL and saves it to the given path.
monitor_new_files(directory, callback)
directory: The folder to monitor.callback: The function to call when new files are detected.- What it does: Continuously checks the directory for new files and triggers the callback with the new file names.
check_if_file_exists(file_path)
file_path: The path of the file to check.- What it does: Returns
Trueif the file exists, otherwiseFalse.
check_internet_connection()
- No arguments.
- What it does: Pings a server (e.g., Google) to check for an active internet connection. Returns
Trueif connected.
create_web_server(directory, port=8000)
directory: The directory to serve files from.port: The port number for the web server (default: 8000).- What it does: Starts a simple HTTP server that serves files from the specified directory.
create_web_server(html, port=8000)
html: The HTML content to serve.port: The port number for the web server (default: 8000).- What it does: Hosts a web server displaying the provided HTML content.
uppercase_list(lst)
lst: A list of strings.- What it does: Converts each string in the list to uppercase and returns the modified list.
remove_duplicates(lst)
lst: A list of items.- What it does: Removes duplicate elements from the list and returns a new list with unique items.
find_index(lst, element)
lst: The list to search.element: The element to find.- What it does: Returns the index of the element in the list, or
-1if not found.
random_element(lst)
lst: A list of items.- What it does: Returns a random item from the list, or
Noneif the list is empty.
validate_email(email)
email: The email address to validate.- What it does: Returns
Trueif the email matches a standard pattern; otherwise,False.
split_into_chunks(text, chunk_size)
text: The string to split.chunk_size: The size of each chunk.- What it does: Splits the text into smaller chunks of the specified size and returns a list of chunks.
evaluate_text_length(text)**
text: The string to analyze.- What it does: Splits the input text into sentences and words. Calculates the average length of words and the average number of words per sentence. Returns a tuple containing the average word length and the average sentence length.
sentiment_analysis(text)**
text: The string to analyze.- What it does: Analyzes the sentiment of the text and returns:
- "Positive" if the sentiment is positive.
- "Negative" if the sentiment is negative.
- "Non Pos Non Neg" if the sentiment is neutral.
analyze_text(text)**
text: The string to analyze.- What it does: Performs a comprehensive analysis of the text, including:
- Word count, sentence count, word frequencies, sentiment analysis, average word and sentence length, and keyword extraction.
- Returns: A dictionary containing all analysis results.
unique_elements(lst)**
lst: The list of elements.- What it does: Removes duplicate elements from the list and returns a list of unique elements.
sum_list(lst)**
lst: The list of numbers.- What it does: Sums all the numbers in the list and returns the total sum.
reverse_list(lst)**
lst: The list of elements.- What it does: Reverses the order of elements in the list and returns the reversed list.
is_prime(n)**
n: The number to check for primality.- What it does: Checks if the number
nis prime by testing divisibility from 2 up to the square root ofn. ReturnsTrueif the number is prime, andFalseotherwise.
shorten_text(text, length)**
text: The string to shorten.length: The maximum length of the shortened string.- What it does: Shortens the input text to the specified length. If the text is longer than the length, it appends "..." at the end.
word_count(text)**
text: The string to analyze.- What it does: Counts the number of words in the text and returns the word count.
is_valid_phone_number(phone_number)**
phone_number: The phone number to validate.- What it does: Validates the phone number based on a regular expression pattern. Returns
Trueif the phone number matches the pattern (international format), otherwise returnsFalse.
clean_null(data)**
data: The list or dictionary to clean.- What it does: Removes
None, empty strings, empty lists, empty dictionaries, andFalsevalues from the data. Returns the cleaned list or dictionary.
calculate_average(numbers)**
numbers: The list of numbers to average.- What it does: Calculates the average (mean) of the numbers in the list. Returns the average value. If the list is empty, returns
0.
calculate_median(numbers)**
numbers: The list of numbers to find the median.- What it does: Sorts the numbers and calculates the median:
- If the list has an odd number of elements, returns the middle number.
- If the list has an even number of elements, returns the average of the two middle numbers.
count_words(text)**
text: The string to analyze.- What it does: Counts the number of words in the text by identifying word boundaries and returns the word count.
count_sentences(text)**
text: The string to analyze.- What it does: Counts the number of sentences in the text by splitting it based on sentence-ending punctuation (e.g.,
.,!,?). Returns the sentence count.
word_frequencies(text)**
text: The string to analyze.- What it does: Calculates the frequency of each word in the text (case-insensitive) and returns a dictionary with words as keys and their frequencies as values.
common_words(text1, text2)**
text1: The first string to compare.text2: The second string to compare.- What it does: Finds the common words between the two input texts. Returns a list of the words that appear in both texts.
extract_keywords(text, n=5)**
text: The string to analyze.n: The number of keywords to extract (default is 5).- What it does: Extracts the top
nkeywords from the text using the TF-IDF (Term Frequency-Inverse Document Frequency) method, excluding common stop words. Returns a list of the topnkeywords based on their importance.
evaluate_text_length(text)
text: The string to analyze.- What it does: Analyzes the text and calculates two key metrics:
- Average word length: The average number of characters per word.
- Average sentence length: The average number of words per sentence.
- Returns: A tuple containing
avg_word_lengthandavg_sentence_length.
sentiment_analysis(text)
text: The string to analyze.- What it does: Performs sentiment analysis using TextBlob to determine whether the text is:
- Positive (if the polarity score is greater than 0),
- Negative (if the polarity score is less than 0),
- Neutral (if the polarity score is exactly 0).
- Returns: A string:
"Positive","Negative", or"Non Pos Non Neg".
Jai(question)
question: A string containing the question you want to ask.- What it does: Uses JynAi to get an answer.Use internet for better answers!
- Returns: A string containing the generated response.
replace(string, replacement, replacment)
string: The original string.replacement: The substring to be replaced.replacment: The new substring that will replace the old one.- What it does: Replaces the first substring (
replacement) in the original string with the new substring (replacment). - Returns: The modified string with the replacement.
containsstr(string1, wic)
string1: The string to search within.wic: The characters or substring to look for.- What it does: Checks if the string contains any of the characters or substrings provided in
wic. It uses regular expressions to search for the matches. - Returns:
Trueif any matching characters or substrings are found; otherwise,False.
split(string, strip_chars)
string: The string to split.strip_chars: Characters to remove from the string.- What it does: Removes the specified characters (
strip_chars) from the string and returns the cleaned string. - Returns: The string with the specified characters removed.
contamath_beta(func)
func: The string or expression to check.- What it does: Checks if the provided string or expression (
func) contains any mathematical operators (+,-,*,/and more). - Returns:
Trueif any mathematical operator is present; otherwise,False.
show_window(root)
- What it does: Shows the windows based on root name.
add_commas(input_string)
input_string: The string you want to add commas to.- What it does: Joins each character of the input string with a comma between them.
- Returns: A string with commas inserted between each character of the input string.
remove_spaces(text)
text: The string from which you want to remove spaces.- What it does: Removes all spaces from the given string.
- Returns: A string without spaces.
remove_spaces_andstickT(text)
text: The string from which spaces are to be removed.- What it does: Uses a regular expression to remove all types of whitespace characters from the input text.
- Returns: A string with all spaces removed.
delfs(input_string, text_to_delete)
input_string: The string from which a specified text will be removed.text_to_delete: The substring that will be deleted from the input string.- What it does: Removes all instances of
text_to_deletefrom the input string. - Returns: A string with the specified text removed.
rem_alphabet(text)
text: The string from which alphabetic characters will be removed.- What it does: Filters out all alphabetic characters (both uppercase and lowercase) from the string.
- Returns: A string containing only non-alphabetic characters.
contamath_beta(func)
func: The string or expression to check.- What it does: Checks if the provided string or expression (
func) contains any mathematical operators (+,-,*,/, or others). - Returns:
Trueif any mathematical operator is present; otherwise,False.
add_commas(input_string)
input_string: The string to which commas need to be added.- What it does: Takes an input string and inserts commas between each character.
- Returns: A string with commas between each character.
remove_spaces(text)
text: The string from which spaces need to be removed.- What it does: Removes all spaces from the provided string.
- Returns: A new string with no spaces.
remove_spaces_andstickT(text)
text: The string from which spaces need to be removed.- What it does: Uses a regular expression to remove all whitespace (including tabs, newlines, etc.) from the string.
- Returns: A new string without any spaces or whitespace characters.
delfs(input_string, text_to_delete)
input_string: The string from which the text needs to be deleted.text_to_delete: The substring that should be removed from the input string.- What it does: Removes the specified
text_to_deletefrom theinput_string. - Returns: A new string with the specified text deleted.
rem_alphabet(text)
text: The string from which alphabetic characters need to be removed.- What it does: Removes all alphabetic characters (letters) from the provided string, keeping only numbers and symbols.
- Returns: A new string with no alphabetic characters.
hotdog(k1="", k2="", k3="", k4="", k5="")
k1, k2, k3, k4, k5: The keys to be pressed.- What it does: Simulates pressing a sequence of keys using
pyautogui’shotkeyfunction. The arguments correspond to keyboard keys. - Returns: No return value (action is executed on the system).
keypress(key)
key: The key to simulate pressing.- What it does: Simulates pressing a single key on the keyboard using
pyautogui. - Returns: No return value (action is executed on the system).
isequal(s, eq)
s: The string to compare.eq: The string to check against.- What it does: Compares two strings, ignoring case, and checks if they are equal.
- Returns:
Trueif both strings are equal (case-insensitive), otherwiseFalse.
contains(s, eq)
s: The string to check.eq: The substring to search for.- What it does: Checks if the string
scontains the substringeq, ignoring case. - Returns:
Trueif the substringeqis found withins, otherwiseFalse.
LoadingBar(Class)
- Attributes:
total_steps: The total number of steps to represent in the loading bar.bar_length: The length of the loading bar (default is 40).progress: The current progress in the loading process.
- Methods:
load(): Updates the loading bar and displays the current progress.finish(): Marks the completion of the loading process by displaying a 100% progress bar.
track_function_start_end(func)
func: The function to track the execution of.- What it does: Wraps a function to track its execution and update the loading bar each time the function starts or finishes.
- Returns: The original function result.
loading_bar(code)
code: A string containing Python code to execute.- What it does: Counts the number of function calls in the provided code and creates a loading bar to track the execution of each function. The code is executed while the loading bar is updated in real-time.
- Returns: No return value; the code is executed and the loading bar is displayed.
nolim(func)**
func: A function that you want to apply the decorator to.- What it does: This is a decorator that modifies the maximum number of digits allowed when converting an integer to a string. It sets the system's integer digit limit (
sys.set_int_max_str_digits) to99 * 99 * 99(970299), preventing excessive number lengths during string conversion operations. - Returns: The original function
funcafter modifying the system's digit limit. The function is executed as normal, but with the updated integer-to-string digit limit in place.
parallel(*functions)
*functions: A list of functions to run in parallel.- What it does: This function executes the provided functions concurrently by creating a new thread for each function. It starts each thread simultaneously, and waits for all threads to finish using
thread.join(). - Returns: No return value; the functions are executed concurrently, and the program waits for all of them to complete before moving forward.
gs(func)
func: A function whose source code you want to retrieve.- What it does: This function uses Python's
inspect.getsource()method to retrieve and return the source code of the provided functionfuncas a string. - Returns: A string containing the source code of the function
func.
ccc(core_count, function, *args, **kwargs)
core_count: The number of CPU cores you want the function to run on.function: The function to execute.*args, **kwargs: Additional arguments and keyword arguments passed to the function.- What it does: This function sets the CPU affinity to the specified number of cores (
core_count) before executing the function. It ensures that the function is only executed on the specified number of cores. Ifcore_countexceeds the available number of cores, it raises aValueError. - Returns: The result of the executed function, with the specified CPU cores applied for the execution.
wait(key="s",num=1)
key: The key value to pick(s --> second ,m --> minute ,h --> hour).num: The number ofs/m/hto wait.- What it does: This function waits the same thing that is with time.sleep function but advantaged
- Returns: Nothing just waits as like
time.sleep.
Jynauth(func, user_name, app_name)
func: The function to execute after successful authentication. This function is passed as an argument and will be called once the OTP is verified correctly.user_name: The user's name, which is used in the QR code URI as part of theissuerfield.app_name: The name of the app, which is included in the QR code URI to link the user with the specific application.- What it does:
- This function manages the entire process of setting up Two-Factor Authentication (2FA) using Time-based One-Time Passwords (TOTP).
- It generates a secret key, creates a QR code that can be scanned by an authenticator app, and provides a user interface to verify the OTP input by the user.
- Once the user inputs the OTP from their authenticator app, the provided function (
func) is executed if the OTP is correct.
- Returns:
- Nothing directly. It creates a window with the QR code and waits for the user to verify the OTP.
-
JwinTheJwinclass creates a Tkinter window where widgets are dynamically configured and displayed based on the layout and configuration provided. The widgets supported are created and managed in a grid layout. Here's how each widget works insideJwin: -
Button Widget
- Widget Type:
"button" - Configuration: In
widgets_config, you can define a button with the widget type as"button". You also define theposition(which row and column it should be placed in) and optional configuration such as the"text"(button label) and"id"(a unique identifier for callbacks). - Behavior: When the button is clicked, the corresponding callback function (if defined in
user_callbacks) is executed. - Example:
{"type": "button", "position": (0, 0), "options": {"text": "Click Me", "id": "button1"}}
- Widget Type:
-
Label Widget
- Widget Type:
"label" - Configuration: A label widget displays text. You specify the
positionand optionally set the"text"and"id"for identification. - Behavior: This widget is for displaying static text in the window.
- Example:
{"type": "label", "position": (1, 0), "options": {"text": "This is a label", "id": "label1"}}
- Widget Type:
-
Input Field Widget
- Widget Type:
"input" - Configuration: An input field where users can type text. You can define its position and optionally provide an
"id". - Behavior: Users can enter text, and the value can be retrieved using the
get_valuemethod. - Example:
{"type": "input", "position": (2, 0), "options": {"id": "input1"}}
- Widget Type:
-
Password Field Widget
- Widget Type:
"password" - Configuration: A password input field that hides the entered text (replaces with asterisks). Like the regular input field, it can be configured with
positionand"id". - Behavior: This widget hides user input and allows for secure text entry.
- Example:
{"type": "password", "position": (3, 0), "options": {"id": "password1"}}
- Widget Type:
-
Checkbox Widget
- Widget Type:
"checkbox" - Configuration: A checkbox allows the user to toggle a true/false value. The
positionand"text"can be customized, and it can also have an"id". - Behavior: Users can toggle the checkbox on or off, and the state can be retrieved using
get_value. - Example:
{"type": "checkbox", "position": (0, 1), "options": {"text": "Accept Terms", "id": "checkbox1"}}
- Widget Type:
-
Dropdown (Combobox) Widget
- Widget Type:
"dropdown" - Configuration: A dropdown menu that allows the user to select one option from a list. You define the
position, a list of"values"to populate the dropdown, and optionally an"id". - Behavior: Users can select an option from the dropdown, and the selected value can be retrieved using
get_value. - Example:
{"type": "dropdown", "position": (1, 1), "options": {"values": ["Option 1", "Option 2"], "id": "dropdown1"}}
- Widget Type:
-
Radio Buttons Widget
- Widget Type:
"radio" - Configuration: A group of radio buttons where users can choose one option. The
positionandvaluesfor each button can be set. Each radio button will share the same"id". - Behavior: Users can select one of the options, and the selected value is saved in a variable. You can retrieve the selected value using
get_value. - Example:
{"type": "radio", "position": (2, 1), "options": {"values": ["Option A", "Option B"], "id": "radio1"}}
- Widget Type:
-
Textarea Widget
- Widget Type:
"textarea" - Configuration: A multi-line text area where users can input large amounts of text. You specify the
positionand an optional"id". - Behavior: The user can enter multiple lines of text, which can be retrieved using
get_value. - Example:
{"type": "textarea", "position": (3, 1), "options": {"id": "textarea1"}}
- Widget Type:
-
Slider Widget
- Widget Type:
"slider" - Configuration: A slider widget that lets users select a value within a specified range. You define
position,minandmaxvalues, and optionally an"id". - Behavior: Users can slide the slider to select a value, which can be retrieved using
get_value. - Example:
{"type": "slider", "position": (0, 2), "options": {"min": 0, "max": 100, "id": "slider1"}}
- Widget Type:
-
Listbox Widget
- Widget Type:
"listbox" - Configuration: A listbox where multiple items can be displayed, and the user can select one. You define
position, a list of"values", and optionally an"id". - Behavior: Users can select a single item from the list, which can be retrieved using
get_value. - Example:
{"type": "listbox", "position": (1, 2), "options": {"values": ["Item 1", "Item 2", "Item 3"], "id": "listbox1"}}
- Widget Type:
-
Canvas Widget
- Widget Type:
"canvas" - Configuration: A drawing area where you can add graphics. You specify the
position, and optionalwidthandheightfor the canvas. - Behavior: This widget allows you to draw graphics on it (e.g., lines, shapes, images). The canvas can be used for custom drawings and visualizations.
- Example:
{"type": "canvas", "position": (2, 2), "options": {"width": 300, "height": 200, "id": "canvas1"}}
- Widget Type:
-
Progressbar Widget
- Widget Type:
"progressbar" - Configuration: A progress bar that visually indicates progress. You can define the
positionand set themode(e.g., "determinate" or "indeterminate"). - Behavior: The progress bar can show the current progress or run in an indeterminate mode. You can control its value programmatically and retrieve its progress.
- Example:
{"type": "progressbar", "position": (3, 2), "options": {"mode": "determinate", "id": "progressbar1"}}
- Widget Type:
-
Spinbox Widget
- Widget Type:
"spinbox" - Configuration: A widget for selecting values within a defined range. You specify the
position,min,max, and optionally an"id". - Behavior: Users can select an integer value from the range by spinning up or down. The selected value can be retrieved using
get_value. - Example:
{"type": "spinbox", "position": (0, 3), "options": {"min": 1, "max": 10, "id": "spinbox1"}}
- Widget Type:
For example:
layout = """
+--------+--------+
|12345678|12345678|
|12345678|12345678|
|12345678|12345678|
+--------+--------+
"""
Define widgets with positions and options
widgets_config = [ {"type": "spinbox", "position": (0, 3), "options": {"min": 1, "max": 10, "id": "spinbox1"}}, {"type": "progressbar", "position": (3, 2), "options": {"mode": "determinate", "id": "progressbar1"}}, {"type": "canvas", "position": (2, 2), "options": {"width": 300, "height": 200, "id": "canvas1"}}, {"type": "listbox", "position": (1, 2), "options": {"values": ["Item 1", "Item 2", "Item 3"], "id": "listbox1"}}, {"type": "slider", "position": (0, 2), "options": {"min": 0, "max": 100, "id": "slider1"}}, {"type": "textarea", "position": (3, 1), "options": {"id": "textarea1"}}, {"type": "radio", "position": (2, 1), "options": {"values": ["Option A", "Option B"], "id": "radio1"}}, {"type": "dropdown", "position": (1, 1), "options": {"values": ["Option 1", "Option 2"], "id": "dropdown1"}}, {"type": "checkbox", "position": (0, 1), "options": {"text": "Accept Terms", "id": "checkbox1"}}, {"type": "password", "position": (3, 0), "options": {"id": "password1"}}, {"type": "input", "position": (2, 0), "options": {"id": "input1"}}, {"type": "label", "position": (1, 0), "options": {"text": "This is a label", "id": "label1"}}, {"type": "button", "position": (0, 0), "options": {"text": "Click Me", "id": "button1"}}, ]
Default callbacks
def button_click_callback(): print("Button clicked!") slider_callback() # Example of chaining callbacks
def checkbox_callback(): print("Checkbox state changed!")
def slider_callback(): slider_value = Jwin.get_value("slider1") # Retrieve slider value dynamically print("Slider value:", slider_value)
def spinbox_callback(): spinbox_value = Jwin.get_value("spinbox1") # Get value from spinbox widget print("Spinbox value:", spinbox_value)
def progressbar_callback(): progress_value = Jwin.get_value("progressbar1") # Get progress from progressbar widget print("Progress bar value:", progress_value)
def canvas_callback(): print("Canvas interaction (e.g., drawing or click) occurred!")
def listbox_callback(): selected_item = Jwin.get_value("listbox1") # Get selected item from listbox print("Listbox selected item:", selected_item)
def textarea_callback(): text_value = Jwin.get_value("textarea1") # Get text from textarea widget print("TextArea content:", text_value)
def radio_callback(): selected_option = Jwin.get_value("radio1") # Get selected radio button option print("Radio button selected option:", selected_option)
def dropdown_callback(): selected_option = Jwin.get_value("dropdown1") # Get selected dropdown option print("Dropdown selected option:", selected_option)
def password_callback(): password_value = Jwin.get_value("password1") # Get entered password from password field print("Password entered:", password_value)
def input_callback(): input_value = Jwin.get_value("input1") # Get input field value print("Input field value:", input_value)
def label_callback(): print("Label was interacted with!")
User-defined callback functions for each widget
user_callbacks = { "button1": button_click_callback, # Button callback "checkbox1": checkbox_callback, # Checkbox callback "slider1": slider_callback, # Slider callback "spinbox1": spinbox_callback, # Spinbox callback "progressbar1": progressbar_callback, # Progress bar callback "canvas1": canvas_callback, # Canvas callback "listbox1": listbox_callback, # Listbox callback "textarea1": textarea_callback, # Textarea callback "radio1": radio_callback, # Radio button callback "dropdown1": dropdown_callback, # Dropdown callback "password1": password_callback, # Password callback "input1": input_callback, # Input callback "label1": label_callback, # Label callback }
-
exists(Filename"): TheFilenameis checks if the file exists. -
Jctb("input string") / Jbtc("input string")Jctb:input stringis input itll return a binary code that can only be undoed by theJbtcfunction. Jbtc:input stringis input thatll only accept the binary code that maden withJctbfunction and return the actual string. -
get_curr_dir(): Returns the current directory the program is runnig.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jynpopmod-2.0.tar.gz.
File metadata
- Download URL: jynpopmod-2.0.tar.gz
- Upload date:
- Size: 38.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c82a8d20169722324d13dfe1ca47634618f287dccc71de532b98e7580518ef3b
|
|
| MD5 |
36015f8f8254b65bfc501525937825ce
|
|
| BLAKE2b-256 |
9ffe30a05385589cb853adfd78128ae97e63cf645494b8a4ec0e8fa7c748165b
|
File details
Details for the file JynPopMod-2.0-py3-none-any.whl.
File metadata
- Download URL: JynPopMod-2.0-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01fd5cc2dfcf971c4ea4ec88eab3b7efe2b2f8a8951d18c5c15bddb3e64d0280
|
|
| MD5 |
e92cdcfafd44740d3910b3eb7b2d775e
|
|
| BLAKE2b-256 |
22b6fb52bc575c2d42f3d52b76f815a67148bc1f34136ccfca54b75f407ca35e
|