add scrollbar change button

This commit is contained in:
vincent 2018-08-23 23:18:39 +02:00
parent 2d2209e640
commit c74fb7a6cc

14
cave.py
View File

@ -1,5 +1,5 @@
import json import json
from tkinter import Scrollbar,Label,LabelFrame,Entry,Button,OptionMenu,StringVar,Canvas,Toplevel,N,S,VERTICAL,Tk,Frame from tkinter import Scrollbar,Label,LabelFrame,Entry,Button,OptionMenu,StringVar,Canvas,Toplevel,N,S,VERTICAL,Tk,Frame,HORIZONTAL,E,W
class Etageres(object): class Etageres(object):
def __init__(self): def __init__(self):
@ -130,7 +130,7 @@ class Bouteille(object):
return data return data
def __repr__(self): def __repr__(self):
return "{},{} ".format(self.appelation, self.millesime) return "{} \n {} ".format(self.appelation, self.millesime)
class EtageresUI(Tk): class EtageresUI(Tk):
@ -141,7 +141,8 @@ class EtageresUI(Tk):
self.etageresUI = [] self.etageresUI = []
self.mainframe=Frame(self) self.mainframe=Frame(self)
vscrollbar = Scrollbar(self.mainframe, orient=VERTICAL) vscrollbar = Scrollbar(self.mainframe, orient=VERTICAL)
self.etagere_frame = Canvas(self.mainframe, yscrollcommand=vscrollbar.set,width=1000,height=1000) hscrollbar = Scrollbar(self.mainframe, orient=HORIZONTAL)
self.etagere_frame = Canvas(self.mainframe,xscrollcommand=hscrollbar.set, yscrollcommand=vscrollbar.set,width=1000,height=1000)
for etagere in self.etageres: for etagere in self.etageres:
newetagere=EtagereUI(etagere, self) newetagere=EtagereUI(etagere, self)
@ -150,7 +151,8 @@ class EtageresUI(Tk):
vscrollbar.grid(column=2, row=1, sticky=N+S) vscrollbar.grid(column=2, row=1, sticky=N+S)
vscrollbar.config(command=self.etagere_frame.yview) vscrollbar.config(command=self.etagere_frame.yview)
hscrollbar.grid(column=1, row=2, sticky=E+W)
hscrollbar.config(command=self.etagere_frame.xview)
framecontrol = LabelFrame(self.mainframe, text="command pannel") framecontrol = LabelFrame(self.mainframe, text="command pannel")
framecontrol.grid(column=3, row=1) framecontrol.grid(column=3, row=1)
Button(framecontrol, text="add etagere", Button(framecontrol, text="add etagere",
@ -270,7 +272,7 @@ class EtagereUI(LabelFrame):
class Cassier_videUI(Button): class Cassier_videUI(Button):
def __init__(self, pos_largeur, pos_hauteur, etagereUI): def __init__(self, pos_largeur, pos_hauteur, etagereUI):
Button.__init__(self, etagereUI, text="cassier vide", Button.__init__(self, etagereUI, text="cassier vide",justify="center",width=15,
command=lambda: self.etagereUI.click_add_bouteille(self)) command=lambda: self.etagereUI.click_add_bouteille(self))
self.pos_largeur = pos_largeur self.pos_largeur = pos_largeur
self.pos_hauteur = pos_hauteur self.pos_hauteur = pos_hauteur
@ -282,7 +284,7 @@ class BouteilleUI(Button):
def __init__(self, bouteille, etagereUI): def __init__(self, bouteille, etagereUI):
self.bouteille = bouteille self.bouteille = bouteille
self.etagereUI = etagereUI self.etagereUI = etagereUI
Button.__init__(self, etagereUI, text=self.bouteille, Button.__init__(self, etagereUI, text=self.bouteille,justify="center",width=15,
command=lambda: self.etagereUI.click_remove_bouteille(self)) command=lambda: self.etagereUI.click_remove_bouteille(self))
self["bg"] = self.etagereUI.etageresUI.etageres.couleur[self.bouteille.couleur] self["bg"] = self.etagereUI.etageresUI.etageres.couleur[self.bouteille.couleur]
self.grid(row=self.bouteille.pos_hauteur, self.grid(row=self.bouteille.pos_hauteur,