Skip to content

Instantly share code, notes, and snippets.

@takpika
Created November 4, 2024 15:22
Show Gist options
  • Select an option

  • Save takpika/bde5034af82be7bff0ab99433fcea3c4 to your computer and use it in GitHub Desktop.

Select an option

Save takpika/bde5034af82be7bff0ab99433fcea3c4 to your computer and use it in GitHub Desktop.
HILOゲームのGUIアプリ(2017/8/25作成)
'''
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
'''
import Tkinter
import random
window = Tkinter.Tk()
money = 10
BET = 0
def bet_up():
global BET
BET = BET + 1
if BET > money:
resultlb.config("You have not enough money")
BET-= 1
moneylb.config(window,text="Money: "+str(money))
def bet_dw():
global BET
BET = BET - 1
if BET < 0:
resultlb.config("Please BET")
BET += 1
moneylb.config(window,text="Money: "+str(money))
def game_starth():
global BET
global money
result = random.randint(0,9)
if BET == 0:
resultlb.config(text="Please BET")
else:
if result >= 5:
resultlb.config(text="You Win!: "+str(result))
moneylb += BET
moneylb.config(window,text="Money: "+str(money))
else:
resultlb.config(text="You Lose.: "+str(result))
moneylb -= BET
moneylb.config(window,text="Money: "+str(money))
def game_startl():
global BET
global money
result = random.randint(0,9)
if BET == 0:
resultlb.config(text="Please BET")
else:
if result <= 5:
resultlb.config(text="You Win!: "+str(result))
moneylb += BET
moneylb.config(window,text="Money: "+str(money))
else:
resultlb.config(text="You Lose.: "+str(result))
moneylb -= BET
moneylb.config(window,text="Money: "+str(money))
def gamers():
global money
global BET
money = 10
BET = 0
resultlb.config(text="Please BET")
moneylb.config(window,text="Money: "+str(money))
moneylb = Tkinter.Label(window,text="Money: "+str(money))
resultlb = Tkinter.Label(window,text="Please BET")
betlb = Tkinter.Label(window,text="BET: "+str(BET))
betupbt = Tkinter.Button(window,text="BET +1",command=bet_up)
betdwbt = Tkinter.Button(window,text="BET -1",command=bet_dw)
hibt = Tkinter.Button(window,text="HI",command=game_starth)
lobt = Tkinter.Button(window,text="LO",command=game_startl)
rsbt = Tkinter.Button(window,text="Reset",command=gamers)
moneylb.pack()
resultlb.pack()
betlb.pack()
betupbt.pack()
betdwbt.pack()
hibt.pack()
lobt.pack()
rsbt.pack()
window.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment