Skip to content

Commit

Permalink
field settings form - added
Browse files Browse the repository at this point in the history
  • Loading branch information
NicTiNereknu committed Aug 7, 2019
1 parent bc47afb commit a7cfcf2
Show file tree
Hide file tree
Showing 11 changed files with 1,047 additions and 19 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@
!pokus_asyncio.py
!setup.py
!settings.jpg
!field.jpg
!field.jpg
!colorSettings_support.py
!colorSettings.py
!colorSettings.tcl
!colorSettings.pkl
Binary file added colorSettings.pkl
Binary file not shown.
422 changes: 422 additions & 0 deletions colorSettings.py

Large diffs are not rendered by default.

415 changes: 415 additions & 0 deletions colorSettings.tcl

Large diffs are not rendered by default.

129 changes: 129 additions & 0 deletions colorSettings_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Support module generated by PAGE version 4.22
# in conjunction with Tcl version 8.6
# Aug 06, 2019 10:47:59 AM CEST platform: Windows NT
# Aug 06, 2019 10:53:45 AM CEST platform: Windows NT
# Aug 06, 2019 12:41:36 PM CEST platform: Windows NT
# Aug 06, 2019 04:57:00 PM CEST platform: Windows NT
# Aug 06, 2019 05:19:33 PM CEST platform: Windows NT
# Aug 06, 2019 05:28:15 PM CEST platform: Windows NT
# Aug 07, 2019 09:42:26 AM CEST platform: Windows NT

import sys
import pickle

try:
import Tkinter as tk
except ImportError:
import tkinter as tk

try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True

class MySave():
nodeRadius = None
horizontalNodeDistance = None
verticalNodeDistance = None
edgeWidthDefault = None
edgeWidthUsed = None
colorNodeDefault = None
colorNodeActual = None
colorEdgeDefault = None
colorEdgePlayer1 = None
colorEdgePlayer2 = None
colorEdgeBorder = None

def __init__(self):
self.nodeRadius = int(varSpnNodeRadius.get())
self.horizontalNodeDistance = int(varSpnHorizontalNodeDistance.get())
self.verticalNodeDistance = int(varSpnVerticalNodeDistance.get())
self.edgeWidthDefault = int(varSpnEdgeWidthDefault.get())
self.edgeWidthUsed = int(varSpnEdgeWidthUsed.get())
self.colorNodeDefault = w.lblColorNodeDefault.cget('bg')
self.colorNodeActual = w.lblColorNodeActual.cget('bg')
self.colorEdgeDefault = w.lblColorEdgeDefault.cget('bg')
self.colorEdgePlayer1 = w.lblColorEdgePlayer1.cget('bg')
self.colorEdgePlayer2 = w.lblColorEdgePlayer2.cget('bg')
self.colorEdgeBorder = w.lblColorEdgeBorder.cget('bg')

def set_Tk_var():
global varSpnNodeRadius
varSpnNodeRadius = tk.StringVar()
global varSpnHorizontalNodeDistance
varSpnHorizontalNodeDistance = tk.StringVar()
global varSpnVerticalNodeDistance
varSpnVerticalNodeDistance = tk.StringVar()
global varSpnEdgeWidthDefault
varSpnEdgeWidthDefault = tk.StringVar()
global varSpnEdgeWidthUsed
varSpnEdgeWidthUsed = tk.StringVar()

def btnCancel_OnClick(p1):
destroy_window()

def lblColorPicker_OnClick(p1):
lbl = p1.widget
lblColor = lbl.cget('bg')
from tkinter.colorchooser import askcolor
color = askcolor(lblColor)
color = color[1]
if color is None: return
lbl.config(bg=color)

def btnSave_OnClick(p1):
#w.fcnSetColorProperties()
# uloz barvy do souboru
with open('colorSettings.pkl', 'wb') as f:
mySave = MySave()
pickle.dump(mySave, f)
w.fcnSetColorProperties()
destroy_window()

def setWidgets():
# nacti barvy ze souboru
with open('colorSettings.pkl', 'rb') as f:
mySave = pickle.load(f)

varSpnNodeRadius.set(str(mySave.nodeRadius))
varSpnHorizontalNodeDistance.set(str(mySave.horizontalNodeDistance))
varSpnVerticalNodeDistance.set(str(mySave.verticalNodeDistance))
varSpnEdgeWidthDefault.set(str(mySave.edgeWidthDefault))
varSpnEdgeWidthUsed.set(str(mySave.edgeWidthUsed))
w.lblColorNodeDefault.config(bg=mySave.colorNodeDefault)
w.lblColorNodeActual.config(bg=mySave.colorNodeActual)
w.lblColorEdgeDefault.config(bg=mySave.colorEdgeDefault)
w.lblColorEdgePlayer1.config(bg=mySave.colorEdgePlayer1)
w.lblColorEdgePlayer2.config(bg=mySave.colorEdgePlayer2)
w.lblColorEdgeBorder.config(bg=mySave.colorEdgeBorder)

pass

def init(top, gui, *args, **kwargs):
global w, top_level, root
w = gui
top_level = top
root = top

w.fcnSetColorProperties = kwargs['fcnSetColorProperties']

setWidgets()

def destroy_window():
# Function which closes the window.
global top_level
top_level.destroy()
top_level = None

if __name__ == '__main__':
import colorSettings
colorSettings.vp_start_gui()




5 changes: 5 additions & 0 deletions field.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,12 @@ def setActualPlayer(self, playerID):
#self.canvasArrowDOWN.place(self.canvasArrowDOWN.pi)
#self.canvasArrowUP.place_forget()

def RGBtoHEX(rgb):
return '#%02x%02x%02x' % rgb

def HEXtoRGB(hex):
hex = hex.lstrip('#')
return( tuple( int(hex[i:i+2], 16) for i in (0, 2, 4) ) )



Expand Down
3 changes: 3 additions & 0 deletions football.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<ItemGroup>
<Compile Include="colorSettings.py" />
<Compile Include="colorSettings_support.py" />
<Compile Include="edge.py" />
<Compile Include="extendSupport.py" />
<Compile Include="field.py" />
Expand All @@ -45,6 +47,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="BorderTypeCombination.csv" />
<Content Include="colorSettings.tcl" />
<Content Include="FieldPointsType.csv" />
<Content Include="FieldPointsTypeCombination.csv" />
<Content Include="gameSettings.tcl" />
Expand Down
26 changes: 20 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# GUI module generated by PAGE version 4.22
# in conjunction with Tcl version 8.6
# Aug 06, 2019 08:39:20 AM CEST platform: Windows NT
# Aug 07, 2019 09:15:53 AM CEST platform: Windows NT

import sys

Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(self, top=None):
self.btnSaveEdgesState.bind('<Button-1>',lambda e:main_support.btnSaveEdgesState_Click(e))

self.Canvas1 = tk.Canvas(top)
self.Canvas1.place(x=130, y=30, height=173, width=113)
self.Canvas1.place(x=130, y=30, height=513, width=373)
self.Canvas1.configure(background="#d9d9d9")
self.Canvas1.configure(borderwidth="2")
self.Canvas1.configure(highlightbackground="#d9d9d9")
Expand All @@ -104,7 +104,7 @@ def __init__(self, top=None):
self.Canvas1.configure(relief="ridge")
self.Canvas1.configure(selectbackground="#c4c4c4")
self.Canvas1.configure(selectforeground="black")
self.Canvas1.configure(width=113)
self.Canvas1.configure(width=373)

self.Label1 = tk.Label(top)
self.Label1.place(x=20, y=400, height=21, width=104)
Expand Down Expand Up @@ -178,7 +178,7 @@ def __init__(self, top=None):
self.txtNumberOfPathsToEndNodes.configure(selectforeground="black")

self.btnSetGameProperties = tk.Button(top)
self.btnSetGameProperties.place(x=20, y=50, height=24, width=83)
self.btnSetGameProperties.place(x=20, y=80, height=24, width=83)
self.btnSetGameProperties.configure(activebackground="#ececec")
self.btnSetGameProperties.configure(activeforeground="#000000")
self.btnSetGameProperties.configure(background="#d9d9d9")
Expand All @@ -187,12 +187,12 @@ def __init__(self, top=None):
self.btnSetGameProperties.configure(highlightbackground="#d9d9d9")
self.btnSetGameProperties.configure(highlightcolor="black")
self.btnSetGameProperties.configure(pady="0")
self.btnSetGameProperties.configure(text='''Set''')
self.btnSetGameProperties.configure(text='''Set game''')
self.btnSetGameProperties.configure(width=30)
self.btnSetGameProperties.bind('<Button-1>',lambda e:main_support.btnSetGameProperties_OnClick(e))

self.btnPlay = tk.Button(top)
self.btnPlay.place(x=20, y=90, height=34, width=83)
self.btnPlay.place(x=20, y=115, height=34, width=83)
self.btnPlay.configure(activebackground="#ececec")
self.btnPlay.configure(activeforeground="#000000")
self.btnPlay.configure(background="#d9d9d9")
Expand Down Expand Up @@ -249,6 +249,20 @@ def __init__(self, top=None):
self.lblPlayer2Name.configure(highlightbackground="#d9d9d9")
self.lblPlayer2Name.configure(highlightcolor="black")

self.btnSetColorProperties = tk.Button(top)
self.btnSetColorProperties.place(x=20, y=50, height=24, width=83)
self.btnSetColorProperties.configure(activebackground="#ececec")
self.btnSetColorProperties.configure(activeforeground="#000000")
self.btnSetColorProperties.configure(background="#d9d9d9")
self.btnSetColorProperties.configure(disabledforeground="#a3a3a3")
self.btnSetColorProperties.configure(foreground="#000000")
self.btnSetColorProperties.configure(highlightbackground="#d9d9d9")
self.btnSetColorProperties.configure(highlightcolor="black")
self.btnSetColorProperties.configure(pady="0")
self.btnSetColorProperties.configure(text='''Set colors''')
self.btnSetColorProperties.configure(width=30)
self.btnSetColorProperties.bind('<Button-1>',lambda e:main_support.btnSetColorProperties_OnClick(e))

# The following code is added to facilitate the Scrolled widgets you specified.
class AutoScroll(object):
'''Configure the scrollbars for a widget.'''
Expand Down
30 changes: 21 additions & 9 deletions main.tcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#############################################################################
# Generated by PAGE version 4.22
# in conjunction with Tcl version 8.6
# Aug 06, 2019 08:39:18 AM CEST platform: Windows NT
# Aug 07, 2019 09:15:51 AM CEST platform: Windows NT
set vTcl(timestamp) ""


Expand Down Expand Up @@ -105,10 +105,10 @@ proc vTclWindow.top42 {base} {
lambda e: btnSaveEdgesState_Click(e)
}
canvas $top.can45 \
-background {#d9d9d9} -borderwidth 2 -closeenough 1.0 -height 173 \
-background {#d9d9d9} -borderwidth 2 -closeenough 1.0 -height 513 \
-highlightbackground {#d9d9d9} -highlightcolor black \
-insertbackground black -relief ridge -selectbackground {#c4c4c4} \
-selectforeground black -width 113
-selectforeground black -width 373
vTcl:DefineAlias "$top.can45" "Canvas1" vTcl:WidgetProc "Toplevel1" 1
label $top.lab46 \
-activebackground {#f9f9f9} -activeforeground black \
Expand Down Expand Up @@ -169,12 +169,11 @@ proc vTclWindow.top42 {base} {
-background {#d9d9d9} -disabledforeground {#a3a3a3} \
-font TkDefaultFont -foreground {#000000} \
-highlightbackground {#d9d9d9} -highlightcolor black -pady 0 \
-text Set -width 30
-text {Set game} -width 30
vTcl:DefineAlias "$top.but47" "btnSetGameProperties" vTcl:WidgetProc "Toplevel1" 1
bind $top.but47 <Button-1> {
lambda e: btnSetGameProperties_OnClick(e)
}
vTcl:copy_lock $top.but47
button $top.but48 \
-activebackground {#ececec} -activeforeground {#000000} \
-background {#d9d9d9} -disabledforeground {#a3a3a3} \
Expand Down Expand Up @@ -209,6 +208,16 @@ proc vTclWindow.top42 {base} {
-font TkDefaultFont -foreground {#000000} \
-highlightbackground {#d9d9d9} -highlightcolor black
vTcl:DefineAlias "$top.lab49" "lblPlayer2Name" vTcl:WidgetProc "Toplevel1" 1
button $top.but49 \
-activebackground {#ececec} -activeforeground {#000000} \
-background {#d9d9d9} -disabledforeground {#a3a3a3} \
-font TkDefaultFont -foreground {#000000} \
-highlightbackground {#d9d9d9} -highlightcolor black -pady 0 \
-text {Set colors} -width 30
vTcl:DefineAlias "$top.but49" "btnSetColorProperties" vTcl:WidgetProc "Toplevel1" 1
bind $top.but49 <Button-1> {
lambda e: btnSetColorProperties_OnClick(e)
}
###################
# SETTING GEOMETRY
###################
Expand All @@ -218,7 +227,7 @@ proc vTclWindow.top42 {base} {
-in $top -x 20 -y 490 -width 95 -relwidth 0 -height 24 -relheight 0 \
-anchor nw -bordermode ignore
place $top.can45 \
-in $top -x 130 -y 30 -width 113 -relwidth 0 -height 173 -relheight 0 \
-in $top -x 130 -y 30 -width 373 -relwidth 0 -height 513 -relheight 0 \
-anchor nw -bordermode ignore
place $top.lab46 \
-in $top -x 20 -y 400 -anchor nw -bordermode ignore
Expand All @@ -237,10 +246,10 @@ proc vTclWindow.top42 {base} {
-in $top -x 30 -y 530 -width 64 -relwidth 0 -height 20 -relheight 0 \
-anchor nw -bordermode ignore
place $top.but47 \
-in $top -x 20 -y 50 -width 0 -relwidth 0.16 -height 0 \
-relheight 0.042 -anchor nw -bordermode ignore
-in $top -x 20 -y 80 -width 83 -relwidth 0 -height 24 -relheight 0 \
-anchor nw -bordermode ignore
place $top.but48 \
-in $top -x 21 -y 94 -width 83 -relwidth 0 -height 34 -relheight 0 \
-in $top -x 21 -y 116 -width 83 -relwidth 0 -height 34 -relheight 0 \
-anchor nw -bordermode ignore
place $top.can46 \
-in $top -x 60 -y 200 -width 48 -relwidth 0 -height 48 -relheight 0 \
Expand All @@ -254,6 +263,9 @@ proc vTclWindow.top42 {base} {
place $top.lab49 \
-in $top -x 60 -y 250 -width 60 -relwidth 0 -anchor nw \
-bordermode ignore
place $top.but49 \
-in $top -x 20 -y 50 -width 83 -height 24 -anchor nw \
-bordermode ignore

vTcl:FireEvent $base <<Ready>>
}
Expand Down
28 changes: 26 additions & 2 deletions main_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Jul 07, 2019 12:57:13 PM CEST platform: Windows NT
# Jul 07, 2019 08:44:09 PM CEST platform: Windows NT
# Jul 23, 2019 12:31:44 PM CEST platform: Windows NT
# Aug 07, 2019 09:15:59 AM CEST platform: Windows NT

import sys
import field
Expand All @@ -17,6 +18,7 @@
import playerAI
import time
import gameSettings
import colorSettings

try:
import Tkinter as tk
Expand All @@ -38,6 +40,29 @@ def __init__(self):
self.edgesUsed = w.Field.getEdgesUsed()
self.actualNodeID = w.Field.actualNode.id


def btnSetColorProperties_OnClick(p1):
colorSettings.create_Toplevel1(root, fcnSetColorProperties=setColorProperties)
debug = 1

def setColorProperties():
# nacti barvy ze souboru
with open('colorSettings.pkl', 'rb') as f:
mySave = pickle.load(f)

w.Field.nodeRadius = mySave.nodeRadius
w.Field.horzNodeDistance = mySave.horizontalNodeDistance
w.Field.vertNodeDistance = mySave.verticalNodeDistance
w.Field.widthEdgeDefault = mySave.edgeWidthDefault
w.Field.widthEdgeUsed = mySave.edgeWidthUsed
w.Field.colorNodeDefault = mySave.colorNodeDefault
w.Field.colorNodeActual = mySave.colorNodeActual
w.Field.colorEdgeDefault = mySave.colorEdgeDefault
w.Field.colorEdgePlayer1 = mySave.colorEdgePlayer1
w.Field.colorEdgePlayer2 = mySave.colorEdgePlayer2
w.Field.colorEdgePlayers = [w.Field.colorEdgePlayer1, w.Field.colorEdgePlayer2]
w.Field.colorEdgeBorder = mySave.colorEdgeBorder

def btnPlay_OnClick(p1):
Field = w.Field
prop = w.gameProperties
Expand Down Expand Up @@ -117,7 +142,6 @@ def changeToplevelAndCanvasSize():
top_newHeight = canvas_y + canvas_newHeight
top_level.geometry("%dx%d" % (top_newWidth, top_newHeight))


def btnSetGameProperties_OnClick(p1):
gameSettings.create_Toplevel1(root, fcnSetGameProperties=setGameProperties,
gameProperties=w.gameProperties)
Expand Down Expand Up @@ -308,6 +332,7 @@ def init(top, gui, *args, **kwargs):
Field = field.Field()
Field.setWidgets(w.Canvas1, w.Label1, w.trvPath, w.canvasArrowUP, w.canvasArrowDOWN)
w.Field = Field
setColorProperties()

def destroy_window():
# Function which closes the window.
Expand All @@ -322,4 +347,3 @@ def destroy_window():




Loading

0 comments on commit a7cfcf2

Please sign in to comment.