Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support printer groups #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions settings-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"printers": [
{
"name": "Printer #1",
"group": "A",
"ip": "192.168.1.1",
"pw": "12345678"
},
{
"name": "Printer #2",
"group": "B",
"ip": "192.168.1.2",
"pw": "12345678"
}
Expand Down
19 changes: 18 additions & 1 deletion src/FarmUpload.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class App():
def __init__(self):
self.settings = None
self.printers = []
self.printerGroups = []
self.fileDirectory = ""

self.ui = tk.Tk()
Expand Down Expand Up @@ -39,14 +40,27 @@ def loadSettings(self):
name = printer["name"],
ip = printer["ip"],
pw = printer["pw"],
enabled = var
enabled = var,
group=printer["group"]
))

checkbox = tk.Checkbutton(self.printerSelectFrame, text=printer["name"], variable=var, onvalue=True, offvalue=False)
checkbox.pack(side=tk.LEFT, pady=10)

if printer["group"] not in self.printerGroups:
self.printerGroups.append(printer["group"])

for group in self.printerGroups:
var = tk.BooleanVar()
groupCheckbox = tk.Checkbutton(self.printerGroupSelectFrame, text=group, variable=var, onvalue=True, offvalue=False, command=lambda g=group, v=var: self.selectGroup(g, v))
groupCheckbox.pack(side=tk.LEFT, pady=10)

self.s.update_idletasks()

def selectGroup(self, group, var):
for printer in [p for p in self.printers if p.group == group]:
printer.enabled.set(var.get())

def loadUI(self):

self.ui.title("FarmUpload")
Expand All @@ -63,6 +77,9 @@ def loadUI(self):
select_printers = tk.Label(self.ui, text="Select which printers to send to:")
select_printers.pack(pady=10)

self.printerGroupSelectFrame = tk.Frame(master=self.ui, highlightbackground="black", highlightthickness=1)
self.printerGroupSelectFrame.pack()

self.printerSelectFrame = tk.Frame(master=self.ui, highlightbackground="black", highlightthickness=1)
self.printerSelectFrame.pack()

Expand Down
3 changes: 2 additions & 1 deletion src/Printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from BambuFTP import BambuFTP

class Printer():
def __init__(self, name, ip, pw, enabled):
def __init__(self, name, ip, pw, enabled, group):
self.name = name;
self.group = group;
self.ip = ip;
self.pw = pw;
self.enabled = enabled
Expand Down