Creating a basic application viewing VM SKU info

I want to create a basic programme which brings a GUI firstly asking what i would like to do? Having 3 options delete a VM, modify a VM, create a VM. Once clicked on one of the options it has a list of VMs showing its disk size, location, vcpu etc. This will be directly inputted into the code on python. I would like the menu to also be present at all times on the GUI. Any help would be really appreicated

I would start by breaking the problem down in to logical steps, and assessing your current skillset. For example, are you able to write Python code? Are you able to create a GUI window? (Do you know what tools might be used to make this work, and have you chosen one?) Do you know how to get information about the VMs from your code, or how to modify, delete or create them from the code?

Also, it’s important to have a clear specification of a problem before trying to solve it. I see at least three issues here:

  1. What exactly do you mean by “This will be directly inputted into the code on python.”? Are you saying that the code will already have the information about the “VMs” written into it? Will the program actually manipulate VMs, or is this just a simulation?

  2. What exactly do you mean by “I would like the menu to also be present at all times on the GUI”? In particular, what menu? And when exactly is “all times”? As long as the program is running? As long as your computer is on? Something else? Why exactly is there a concern, that the menu (whatever it is) could disappear at the wrong time?

  3. The title for your post mentions “SKU”, but your post doesn’t. I understand SKU to mean this, and VM to mean this, so I can’t understand how they have anything to do with each other.

I have this code created to give a better picture trouble im now facing is after when ive pressed the button for delete, how can i make each button delete…add…modify the vm. So for example when i try after pressing the delete button and entering the password. When selecting the vm how can i get this deleted stay deleted if i go back into it, same for adding vm and modifying vm

import tkinter as tk
from tkinter import messagebox, simpledialog

class VirtualMachineApp:
def init(self, root):
self.root = root
self.root.title(“Virtual Machine Manager”)

    # Initialize frames
    self.main_frame = tk.Frame(root)
    self.vm_list_frame = tk.Frame(root)
    self.vm_details_frame = tk.Frame(root)

    # Show the main menu frame initially

    # Add an exit button to the root window
    self.exit_button = tk.Button(root, text="Exit", command=root.quit)

def show_main_menu(self):
    # Clear all widgets from the main frame
    for widget in self.main_frame.winfo_children():

    # Create main menu label
    self.main_menu_label = tk.Label(self.main_frame, text="What would you like to do today?")

    # Create buttons for Modify, Update, Add, and Delete
    self.modify_button = tk.Button(self.main_frame, text="Modify Virtual Machine", command=self.check_password)
    self.update_button = tk.Button(self.main_frame, text="Update Virtual Machine", command=self.check_password)
    self.add_button = tk.Button(self.main_frame, text="Add Virtual Machine", command=self.check_password)
    self.delete_button = tk.Button(self.main_frame, text="Delete", command=self.check_password)

    # Pack buttons

    # Create a list of virtual machines (you can replace this with your data)
    self.virtual_machines = [
        {"name": "VM1", "vcpu": 2, "location": "Datacenter A", "disk_size": "100 GB", "last_used": "2023-03-20"},
        {"name": "VM2", "vcpu": 4, "location": "Datacenter B", "disk_size": "200 GB", "last_used": "2023-03-21"},
        # Add more VMs here...

def check_password(self):
    password = simpledialog.askstring("Password", "Enter password:", show='*')
    if password == "1234":
        messagebox.showerror("Error", "Incorrect password.")

def show_vm_list(self):
    # Clear all widgets from the VM list frame
    for widget in self.vm_list_frame.winfo_children():


    # Display the list of virtual machines
    self.vm_listbox = tk.Listbox(self.vm_list_frame)
    for vm in self.virtual_machines:
        vm_info = f"Name: {vm['name']}, vCPU: {vm['vcpu']}, Location: {vm['location']}, Disk Size: {vm['disk_size']}, Last Used: {vm['last_used']}"
        self.vm_listbox.insert(tk.END, vm_info)

    # Add a button to return to the main menu
    main_menu_button = tk.Button(self.vm_list_frame, text="Main Menu", command=self.show_main_menu)

    # Add a button to show VM details
    details_button = tk.Button(self.vm_list_frame, text="Show Details", command=self.show_vm_details)

def show_vm_details(self):
    # Clear all widgets from the VM details frame
    for widget in self.vm_details_frame.winfo_children():


    # Get the selected VM from the listbox
    selected_vm_index = self.vm_listbox.curselection()
    if not selected_vm_index:
        messagebox.showerror("Error", "Please select a VM.")

    self.selected_vm = self.virtual_machines[selected_vm_index[0]]

    # Create labels and entry fields for each property
    tk.Label(self.vm_details_frame, text="Name:").pack()
    self.name_entry = tk.Entry(self.vm_details_frame)
    self.name_entry.insert(0, self.selected_vm["name"])

    tk.Label(self.vm_details_frame, text="vCPU:").pack()
    self.vcpu_entry = tk.Entry(self.vm_details_frame)
    self.vcpu_entry.insert(0, self.selected_vm["vcpu"])

    # Add more labels and entry fields for other properties (location, disk size, last used)

    # Add a button to save changes
    save_button = tk.Button(self.vm_details_frame, text="Save Changes", command=self.save_vm_changes)

    # Add a button to return to the main menu
    main_menu_button = tk.Button(self.vm_details_frame, text="Main Menu", command=self.show_main_menu)

def save_vm_changes(self):
    # Get modified values from entry fields
    modified_name = self.name_entry.get()
    modified_vcpu = int(self.vcpu_entry.get())

    # Update the selected VM's properties
    self.selected_vm["name"] = modified_name
    self.selected_vm["vcpu"] = modified_vcpu

    # Update the listbox item
    selected_vm_index = self.vm_listbox.curselection()[0]
    vm_info = f"Name: {self.selected_vm['name']}, vCPU: {self.selected_vm['vcpu']}, Location: {self.selected_vm['location']}, Disk Size: {self.selected_vm['disk_size']}, Last Used: {self.selected_vm['last_used']}"
    self.vm_listbox.insert(selected_vm_index, vm_info)

def hide_all_frames(self):

if name == “main”:
root = tk.Tk()
app = VirtualMachineApp(root)

So I have my application with just the following I would like to add.

  • after pressing modify button, shows me details and allows me to change VM details, such as name…location…vcpu.
    -after pressing delete button, shows me VM list and when I select one it removes it from the list.
  • after pressing add button, allows me to enter details to add a VM to the existing list.
    other issue with my code is because all buttons delete, add, modify let me view but then after going back to main menu and viewing the machines again the details haven’t stayed the same. Any help would be really appreciated.

It should just be VM details.
Name: VM1, VCPU: 4, Location etc… I have enter more detail below to give a better picture now