ok here we go
|
@ -0,0 +1,5 @@
|
|||
freeze_frame.jpg
|
||||
qr.jpg
|
||||
users.json
|
||||
merged_image.jpg
|
||||
drawing.png
|
27
addtoDB.py
|
@ -27,20 +27,25 @@ def main():
|
|||
|
||||
|
||||
|
||||
def addToSSB(pathToImage,description):
|
||||
#SEND TO SSB! WOOOO
|
||||
try:
|
||||
result = subprocess.Popen('./ssb-post.sh mint "' + description + '" ' + pathToImage, shell=True, stdout=subprocess.PIPE, )
|
||||
except:
|
||||
print('traceback.format_exc():\n%s' % traceback.format_exc())
|
||||
exit()
|
||||
def addToSSB(pathToImage,description,mintOrGive):
|
||||
|
||||
# for testing:
|
||||
#print(result)
|
||||
# mint
|
||||
if mintOrGive == 1:
|
||||
try:
|
||||
result = subprocess.Popen('./ssb-post.sh mint "' + description + '" ' + pathToImage, shell=True, stdout=subprocess.PIPE, )
|
||||
except:
|
||||
print('traceback.format_exc():\n%s' % traceback.format_exc())
|
||||
exit()
|
||||
|
||||
# else give
|
||||
elif mintOrGive == 2:
|
||||
try:
|
||||
result = subprocess.Popen('./ssb-post.sh give "' + pathToImage + '" ' + description, shell=True, stdout=subprocess.PIPE, )
|
||||
except:
|
||||
print('traceback.format_exc():\n%s' % traceback.format_exc())
|
||||
exit()
|
||||
|
||||
# get the ssb json from the bash command we just ran
|
||||
#newssb=result.stdout.read()
|
||||
##chatgpt's version:
|
||||
newssb = result.stdout.read().decode() # decode bytes to string
|
||||
print(newssb)
|
||||
|
||||
|
|
BIN
drawing.png
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 8.7 KiB |
BIN
freeze_frame.jpg
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 24 KiB |
BIN
freeze_frame.png
Before Width: | Height: | Size: 325 KiB |
158
kiosk6.py
|
@ -1,9 +1,12 @@
|
|||
## this is the custodisco kiosk code for dweb camp 2023
|
||||
|
||||
import tkinter as tk
|
||||
from tkinter import font as tkfont
|
||||
from tkinter import Canvas
|
||||
from tkinter import ttk
|
||||
from tkinter import Text
|
||||
from PIL import Image, ImageTk, ImageDraw
|
||||
from tkinter import messagebox
|
||||
import tozpl
|
||||
import subprocess
|
||||
import threading
|
||||
|
@ -23,6 +26,7 @@ class Kiosk(tk.Tk):
|
|||
self.frames_history = []
|
||||
self.geometry('1366x768')
|
||||
self.attributes('-fullscreen', True)
|
||||
self.config(cursor="crosshair")
|
||||
self.switch_frame(Screen0)
|
||||
|
||||
def switch_frame(self, frame_class, keep_history=True):
|
||||
|
@ -82,6 +86,8 @@ class Screen1(tk.Frame):
|
|||
# find yourself in list of ssb users
|
||||
class Screen2(tk.Frame):
|
||||
selected_user = None # This is the global variable to store selected user
|
||||
selected_label = None # This is the global variable to store selected label
|
||||
|
||||
def __init__(self, master):
|
||||
tk.Frame.__init__(self, master, bg='#bcfef9')
|
||||
|
||||
|
@ -89,14 +95,6 @@ class Screen2(tk.Frame):
|
|||
self.top_frame = tk.Frame(self)
|
||||
self.top_frame.pack(side="top", fill="x", pady=40)
|
||||
|
||||
# The 'Done' button to navigate to next screen
|
||||
self.done_button = tk.Button(self, text="Done", command=lambda: master.switch_frame(Screen3), height=3, width=30, bg='peach puff', font=('Helvetica', 16))
|
||||
self.done_button.pack(side="right", padx=20, pady=10)
|
||||
|
||||
# The 'Refresh List' button
|
||||
self.refresh_button = tk.Button(self, text="Refresh List (takes a minute)", command=self.refresh_users, height=3, width=30, bg='peach puff', font=('Helvetica', 16))
|
||||
self.refresh_button.pack(side="right", padx=20, pady=10)
|
||||
|
||||
# Add a label and text box to the top frame
|
||||
self.label = tk.Label(self.top_frame, text="Start typing your public key to find yourself in the list then click on your key to select it.", font=('Helvetica', 16))
|
||||
self.label.pack(side="left")
|
||||
|
@ -109,19 +107,30 @@ class Screen2(tk.Frame):
|
|||
|
||||
# Create container for user list
|
||||
self.container = ttk.Frame(self, height=500) # Define a height here
|
||||
self.container.pack(fill='both', expand=True)
|
||||
|
||||
self.container.pack(fill='both', expand=True, padx=20, pady=20)
|
||||
|
||||
# Initialize users list from users.json
|
||||
self.users = self.get_users_from_file()
|
||||
self.update_users_list()
|
||||
|
||||
# The 'Done' button to navigate to next screen
|
||||
self.done_button = tk.Button(self, text="Done", command=lambda: master.switch_frame(Screen3), height=3, width=30, bg='peach puff', font=('Helvetica', 16))
|
||||
self.done_button.pack(side="bottom", padx=20, pady=10)
|
||||
|
||||
# The 'Refresh List' button
|
||||
self.refresh_button = tk.Button(self, text="Refresh List (takes a minute)", command=self.refresh_users, height=3, width=30, bg='peach puff', font=('Helvetica', 16))
|
||||
self.refresh_button.pack(side="bottom", padx=20, pady=10)
|
||||
|
||||
master.add_home_button(self)
|
||||
|
||||
|
||||
def refresh_users(self):
|
||||
# Update users list from Scuttlebutt and display it
|
||||
self.users = self.get_scuttlebutt_users()
|
||||
self.update_users_list()
|
||||
try:
|
||||
# Update users list from Scuttlebutt and display it
|
||||
self.users = self.get_scuttlebutt_users()
|
||||
self.update_users_list()
|
||||
except Exception as e:
|
||||
print(f"An error occurred while refreshing the user list: {e}")
|
||||
messagebox.showerror("Error", "An error occurred while refreshing the user list. Please try again later.")
|
||||
|
||||
def get_scuttlebutt_users(self):
|
||||
result = subprocess.run(['node', 'scuttlebot.js'], capture_output=True, text=True)
|
||||
|
@ -150,8 +159,11 @@ class Screen2(tk.Frame):
|
|||
|
||||
def display_users(self, users):
|
||||
# Scrollable list of users
|
||||
canvas = tk.Canvas(self.container, width=500) # Increase the width if necessary
|
||||
scrollbar = ttk.Scrollbar(self.container, orient='vertical', command=canvas.yview)
|
||||
canvas = tk.Canvas(self.container, width=460) # Decrease the width by scrollbar's width
|
||||
style = ttk.Style()
|
||||
style.configure("Vertical.TScrollbar", gripcount=0,
|
||||
arrowsize=15, width=40) # Adjust width here
|
||||
scrollbar = ttk.Scrollbar(self.container, orient='vertical', command=canvas.yview, style="Vertical.TScrollbar")
|
||||
scrollable_frame = ttk.Frame(canvas)
|
||||
|
||||
scrollable_frame.bind(
|
||||
|
@ -164,25 +176,35 @@ class Screen2(tk.Frame):
|
|||
canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
|
||||
canvas.configure(yscrollcommand=scrollbar.set)
|
||||
|
||||
# Add user labels to scrollable frame
|
||||
# Add user buttons to scrollable frame
|
||||
for user in users:
|
||||
label = tk.Label(scrollable_frame, text=user['id'], font=('Helvetica', 16))
|
||||
label.bind("<Button-1>", self.on_user_clicked)
|
||||
label.pack(anchor="w")
|
||||
button = tk.Button(scrollable_frame, text=user['id'], font=('Helvetica', 24), bd=0) # Adjust font size here
|
||||
button.pack(anchor="w")
|
||||
button.config(command=lambda button=button, user=user: self.on_user_clicked(button, user))
|
||||
|
||||
canvas.pack(side="left", fill="both", expand=True)
|
||||
scrollbar.pack(side="right", fill="y")
|
||||
|
||||
def on_user_clicked(self, event):
|
||||
def widget_exists(self, widget):
|
||||
try:
|
||||
widget.winfo_exists()
|
||||
return True
|
||||
except tk.TclError:
|
||||
return False
|
||||
|
||||
def on_user_clicked(self, button, user):
|
||||
# Remove highlight from previously selected user
|
||||
if Screen2.selected_user is not None:
|
||||
self.selected_user.configure(bg=self.container.cget("bg"))
|
||||
if Screen2.selected_label is not None and self.widget_exists(Screen2.selected_label):
|
||||
Screen2.selected_label.configure(relief=tk.FLAT, bg='SystemButtonFace') # default color
|
||||
|
||||
# Store selected user and button
|
||||
Screen2.selected_user = user['id']
|
||||
Screen2.selected_label = button
|
||||
|
||||
# Highlight clicked label
|
||||
event.widget.configure(bg="light blue")
|
||||
Screen2.selected_label.configure(relief=tk.SUNKEN, bg="light blue")
|
||||
|
||||
|
||||
# Store selected user
|
||||
Screen2.selected_user = event.widget.cget("text")
|
||||
|
||||
|
||||
#take photo of item
|
||||
|
@ -306,81 +328,99 @@ class Screen8(tk.Frame):
|
|||
def __init__(self, master):
|
||||
tk.Frame.__init__(self, master, bg='#bcfef9')
|
||||
|
||||
# Creating a frame for the left side of the screen for drawing and right side for the buttons
|
||||
# Creating a frame for the left side of the screen for drawing
|
||||
self.left_frame = tk.Frame(self, bg='#bcfef9')
|
||||
self.left_frame.pack(side='left', padx=50)
|
||||
|
||||
# Frame for the instructions
|
||||
self.center_frame = tk.Frame(self, bg='#bcfef9')
|
||||
self.center_frame.pack(side='left', padx=50)
|
||||
|
||||
# Frame for the tools
|
||||
self.right_frame = tk.Frame(self, bg='#bcfef9')
|
||||
self.left_frame.pack(side='left', padx=10)
|
||||
self.right_frame.pack(side='right', padx=10)
|
||||
self.right_frame.pack(side='left', padx=50)
|
||||
|
||||
# Add instructions
|
||||
self.label = tk.Label(self.left_frame, text="You may now draw your tag! This will be printed as either a sticker or a ribbon, both of which are 1.25 by 2.25 inches. You can include contact info for yourself, the name of the item, a drawing, or whatever you want, it's your artistic expression. In the bottom right will be a small QR code which links to the Scuttlebutt post for your item.",
|
||||
wraplength=500, # adjust to suit needs
|
||||
self.label = tk.Label(self.center_frame, text="You may now draw your tag! This will be printed as either a sticker or a ribbon, both of which are 1.25 by 2.25 inches. You can include contact info for yourself, the name of the item, a drawing, or whatever you want, it's your artistic expression. In the bottom right will be a small QR code which links to the Scuttlebutt post for your item. The image you are drawing now will not be posted to Scuttlebutt.",
|
||||
wraplength=400, # adjust to suit needs
|
||||
font=("Helvetica", 16))
|
||||
self.label.pack(pady=20)
|
||||
|
||||
self.drawing = Image.new('1', (300, 540), 1)
|
||||
self.label.pack(pady=50)
|
||||
|
||||
# is this the drawing area?
|
||||
self.drawing = Image.new('1', (361, 675), 1)
|
||||
self.draw = ImageDraw.Draw(self.drawing)
|
||||
self.last_draw = None
|
||||
|
||||
# Set initial drawing color to black
|
||||
# Set initial drawing color to black and size to 1
|
||||
self.draw_color = 'black'
|
||||
self.draw_size = 1
|
||||
|
||||
# Creating the Canvas for drawing
|
||||
self.canvas = Canvas(self.left_frame, width=300, height=540, bg='white')
|
||||
self.canvas = Canvas(self.left_frame, width=361, height=675, bg='white')
|
||||
self.canvas.bind("<B1-Motion>", self.draw_line)
|
||||
self.canvas.pack(pady=20)
|
||||
self.canvas.bind("<ButtonRelease-1>", self.reset_last_draw)
|
||||
self.add_qr_box() # Add QR box to the canvas
|
||||
|
||||
|
||||
#Create a frame for the buttons grid
|
||||
self.buttons_frame = tk.Frame(self.right_frame, bg='#bcfef9')
|
||||
self.buttons_frame.pack(pady=10)
|
||||
|
||||
# Add Draw Size buttons
|
||||
tk.Button(self.buttons_frame, text=".", command=lambda: self.set_draw_size(1), height=3, width=10, bg='peach puff').grid(row=0, column=0, padx=5, pady=5)
|
||||
tk.Button(self.buttons_frame, text="*", command=lambda: self.set_draw_size(2), height=3, width=10, bg='peach puff').grid(row=1, column=0, padx=5, pady=5)
|
||||
tk.Button(self.buttons_frame, text="⚬", command=lambda: self.set_draw_size(3), height=3, width=10, bg='peach puff').grid(row=2, column=0, padx=5, pady=5)
|
||||
tk.Button(self.buttons_frame, text="⬤", command=lambda: self.set_draw_size(4), height=3, width=10, bg='peach puff').grid(row=3, column=0, padx=5, pady=5)
|
||||
|
||||
# Creating color buttons
|
||||
tk.Button(self.right_frame, height=10, width=10, bg='black', command=lambda: self.set_draw_color('black')).pack(pady=5)
|
||||
tk.Button(self.right_frame, height=10, width=10, bg='white', command=lambda: self.set_draw_color('white')).pack(pady=5)
|
||||
tk.Button(self.buttons_frame, height=5, width=10, bg='black', command=lambda: self.set_draw_color('black')).grid(row=0, column=1, padx=5, pady=5)
|
||||
tk.Button(self.buttons_frame, height=5, width=10, bg='white', command=lambda: self.set_draw_color('white')).grid(row=1, column=1, padx=5, pady=5)
|
||||
|
||||
# Add label for pen color buttons
|
||||
self.color_label = tk.Label(self.right_frame, text="switch pen color", font=("Helvetica", 16))
|
||||
self.color_label = tk.Label(self.right_frame, text="^ drawing tools ^", font=("Helvetica", 16))
|
||||
self.color_label.pack(pady=5)
|
||||
|
||||
# Add Clear Drawing Button
|
||||
tk.Button(self.right_frame, text="clear drawing", command=self.clear_drawing, height=3, width=20, bg='peach puff').pack(pady=10)
|
||||
|
||||
# done button
|
||||
# Done button
|
||||
tk.Button(self.right_frame, text="Done", command=self.next, height=3, width=30, bg='peach puff').pack(pady=10)
|
||||
|
||||
# Adding a home button
|
||||
master.add_home_button(self.right_frame)
|
||||
master.add_home_button(self.center_frame)
|
||||
|
||||
def draw_line(self, event):
|
||||
x, y = event.x, event.y
|
||||
if self.last_draw:
|
||||
self.canvas.create_line(*self.last_draw, x, y, fill=self.draw_color)
|
||||
self.draw.line([*self.last_draw, x, y], fill=0 if self.draw_color == 'black' else 1)
|
||||
self.canvas.create_line(*self.last_draw, x, y, fill=self.draw_color, width=self.draw_size)
|
||||
self.draw.line([*self.last_draw, x, y], fill=0 if self.draw_color == 'black' else 1, width=self.draw_size)
|
||||
self.last_draw = (x, y)
|
||||
|
||||
def next(self):
|
||||
|
||||
# Save the drawing as a .png file
|
||||
self.drawing.save("drawing.png")
|
||||
|
||||
# next screen
|
||||
self.master.switch_frame(Screen11)
|
||||
|
||||
|
||||
def reset_last_draw(self, event):
|
||||
self.last_draw = None
|
||||
|
||||
def set_draw_color(self, color):
|
||||
self.draw_color = color
|
||||
|
||||
def set_draw_size(self, size):
|
||||
self.draw_size = size
|
||||
|
||||
def clear_drawing(self):
|
||||
self.canvas.delete("all") # Clear canvas
|
||||
self.drawing = Image.new('1', (300, 540), 1) # Create new blank drawing image
|
||||
self.drawing = Image.new('1', (361, 675), 1) # Create new blank drawing image
|
||||
self.draw = ImageDraw.Draw(self.drawing) # Prepare to draw on the new blank image
|
||||
self.add_qr_box() # Add QR box to the canvas
|
||||
|
||||
def add_qr_box(self):
|
||||
self.canvas.create_rectangle(300-43, 540-43, 300, 540, outline='black', fill='white')
|
||||
self.canvas.create_text(300-22, 540-22, text="QR", fill="black")
|
||||
|
||||
self.canvas.create_rectangle(232, 546, 361, 667, outline='black', fill='white')
|
||||
self.canvas.create_text(300, 600, text="QR", fill="black")
|
||||
|
||||
# txt update
|
||||
class Screen9(tk.Frame):
|
||||
|
@ -424,14 +464,18 @@ class Screen11(tk.Frame):
|
|||
path_to_image = "/home/trav/Documents/custodiosk/freeze_frame.jpg"
|
||||
|
||||
# make ssb post
|
||||
key = addtoDB.addToSSB(path_to_image,info_text)
|
||||
key = addtoDB.addToSSB(path_to_image,info_text,1)
|
||||
|
||||
# ssb give! (make sure we have a UID to give to first)
|
||||
if Screen2.selected_user != "":
|
||||
nothing = addtoDB.addToSSB(Screen2.selected_user,key,2)
|
||||
|
||||
# Create qr code
|
||||
#from https://ourcodeworld.com/articles/read/554/how-to-create-a-qr-code-image-or-svg-in-python
|
||||
qr = qrcode.QRCode(
|
||||
version = 1,
|
||||
error_correction = qrcode.constants.ERROR_CORRECT_H,
|
||||
box_size = 1,
|
||||
box_size = 3,
|
||||
border = 1,
|
||||
)
|
||||
# Add data
|
||||
|
@ -447,9 +491,9 @@ class Screen11(tk.Frame):
|
|||
qr = Image.open("qr.jpg") # qr
|
||||
|
||||
# merge em
|
||||
merged_image = Image.new('L', drawing.size)
|
||||
merged_image.paste(drawing, (0, 0))
|
||||
merged_image.paste(qr, (257, 497)) # paste without mask
|
||||
merged_image = Image.new('L', (367, 725), "white")
|
||||
merged_image.paste(drawing, (0, 25))
|
||||
merged_image.paste(qr, (232, 571)) # paste without mask
|
||||
merged_image.save("merged_image.png")
|
||||
|
||||
|
||||
|
@ -489,10 +533,6 @@ class Screen11(tk.Frame):
|
|||
print('traceback.format_exc():\n%s' % traceback.format_exc())
|
||||
exit()
|
||||
|
||||
|
||||
# post update to SSB transferring ownership to the user
|
||||
# fill this in ^^^
|
||||
|
||||
self.master.switch_frame(Screen10) # Switching to Screen10 after Done
|
||||
|
||||
class Screen12(tk.Frame):
|
||||
|
|
BIN
merged_image.png
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 13 KiB |
BIN
qr.jpg
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 690 B |
20
ssb-post.sh
|
@ -4,9 +4,8 @@
|
|||
|
||||
|
||||
## ok we need to be passed a number of arguments
|
||||
## item description = $2
|
||||
## image path = $3
|
||||
## give to account = $4
|
||||
## item description/GIVE to account ID = $2
|
||||
## image path/messageID of existing item = $3
|
||||
|
||||
|
||||
if [ -z "$1" ]
|
||||
|
@ -49,7 +48,20 @@ fi
|
|||
## give
|
||||
if [ "$1" == "give" ]
|
||||
then
|
||||
:
|
||||
account=$2
|
||||
messageID=$3
|
||||
|
||||
ssb-server publish . <<BLAAB
|
||||
{
|
||||
"type":"post",
|
||||
"text":"I'm giving this item to $account!",
|
||||
"custodisco":"true",
|
||||
"nft": "give",
|
||||
"target": "$account",
|
||||
"root": "$messageID",
|
||||
"branch": "$messageID"
|
||||
}
|
||||
BLAAB
|
||||
fi
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
^XA
|
||||
^JUN
|
||||
^XZ
|
||||
^XA
|
||||
^JUS
|
||||
^XZ
|
BIN
testqr.png
Before Width: | Height: | Size: 422 B |