OZmium Sports Betting and Horse Racing Forums

OZmium Sports Betting and Horse Racing Forums (http://forums.ozmium.com.au/index.php)
-   General Topics (http://forums.ozmium.com.au/forumdisplay.php?f=59)
-   -   Python help using tkinter (http://forums.ozmium.com.au/showthread.php?t=32133)

chook 14th October 2020 01:44 PM

i hope this gets pasted properly
####### add row number
rowo = 0
for Venue in Venues:
Rtype = Venue["raceType"]
Mname = Venue["meetingName"]
Location = Venue["location"]
###### weather and track condition might not be there
if "weatherCondition" in Venue: Wcondition = Venue["weatherCondition"]
else: Wcondition = "BLEEK"
if "trackCondition" in Venue: Tcondition = Venue["trackCondition"]
else: Tcondition = "TkCoon"
states = ("VIC","NSW","QLD","SA","WA","TAS","ACT")
if Rtype == "R" and Location in states:
#Race Info
Mname_label = Label(Rinfo, text=Mname, font=("bold", 12), width=15, anchor=W, bg="Red")
Mname_label.grid(column=0, sticky=W,row=rowo)
Location_label = Label(Rinfo, text=Location, font=("bold", 12), width=5 ,anchor=W, bg="Pink")
Location_label.grid(column=2, sticky=W,row=rowo)
Tcondition_label = Label(Rinfo, text=Tcondition, font=("bold", 12), width=10 ,anchor=W, bg="Magenta")
Tcondition_label.grid(column=3, sticky=W,row=rowo)
Wcondition_label = Label(Rinfo, text=Wcondition, font=("bold", 12), width=10 ,anchor=W, bg="Lightblue")
Wcondition_label.grid(column=4, sticky=W,row=rowo)
##### increment row number
rowo += 1

# Date Selection Frame

#### end of paste

HTH

Shaun 27th October 2020 12:04 AM

I have almost finished this app, pretty happy with it, just have a small issue i can't resolve.

normally when returning data you will have key pairs to work with but the results are not exactly the same.

Code:
"results":[ [ 8 ], [ 4 ], [ 2 ], [ 9 ] ],


how can i return the number?

Shaun 27th October 2020 12:25 PM

Here is an almost finished project exe, it is missing a few things like race start time and results and maybe some instructions.

Just run it, select "Today" or "Tomorrow" highlight the "M-Code" for the meeting you want then put in a race number and press "Get Race"

It gives you some info in regards to ratings used on tab site, i also noted they show the same fixed prices for all the sites.

This is the first program i have written in like 30 years and the first in python, it may be a simple program to some but i am pretty pleased with my efforts as it gave me a better understanding of python i guess, the source code is not pretty and am sure it could be tidied up as there are a few errors.

the program is in my One Drive folder in my signature called "Tab_Prices" there is also a text doc with the python code in there.

Shaun 28th October 2020 12:48 AM

I added a 30 second refresh, you can still switch races.

Shaun 7th November 2020 08:15 AM

This program now collects the results if known and updates every 15 seconds, i would like to colour code the results 1st to 4th, i have tried a few ways but unsuccessful, i have updated the code script if anyone has ideas.

I noticed a bug, will update file when fixed

Playlife 7th November 2020 04:21 PM

Quote:
Originally Posted by Shaun
Here is an almost finished project exe, it is missing a few things like race start time and results and maybe some instructions.

Just run it, select "Today" or "Tomorrow" highlight the "M-Code" for the meeting you want then put in a race number and press "Get Race"

It gives you some info in regards to ratings used on tab site, i also noted they show the same fixed prices for all the sites.

This is the first program i have written in like 30 years and the first in python, it may be a simple program to some but i am pretty pleased with my efforts as it gave me a better understanding of python i guess, the source code is not pretty and am sure it could be tidied up as there are a few errors.

the program is in my One Drive folder in my signature called "Tab_Prices" there is also a text doc with the python code in there.



EDIT, I do apologise, this only seems to work for VIC.


Hi Shaun, great job.

Unfortunately the move to this new API killed my excel/VBA work as well. I'm new to python, slowly learning the ropes.

It is as clunky as hell, and is manually coded, but using your script I have added the start time. Programmers will wince at how bad this is (sorry!). There's easier ways to do timezone conversions so I have read but cannot wrap my head around it yet.


**** inserted into # race info ****
race_StartTime = race1["raceStartTime"]
****
d1 = datetime.datetime.strptime(race_StartTime,"%Y-%m-%dT%H:%M:%S.%fZ")
new_format = "%H:%M"
HourOnly = "%H"
MinuteOnly = "%M"
Hour = str(int(d1.strftime(HourOnly))+11) # This is for Victoria AEDT (+11 hrs GMT)
Minute = d1.strftime(MinuteOnly)
race_StartTime = "Jump:" + Hour + ":" + Minute

raceStartTime = Label(inputFrame, text=str(race_StartTime), width=25, bg="darkblue", fg="white", font=("bold", 11), anchor=W)
raceStartTime.grid(row=0, column=20)

****

Shaun 7th November 2020 11:31 PM

Quote:
Originally Posted by Playlife
EDIT, I do apologise, this only seems to work for VIC.


Hi Shaun, great job.

Unfortunately the move to this new API killed my excel/VBA work as well. I'm new to python, slowly learning the ropes.

It is as clunky as hell, and is manually coded, but using your script I have added the start time. Programmers will wince at how bad this is (sorry!). There's easier ways to do timezone conversions so I have read but cannot wrap my head around it yet.


**** inserted into # race info ****
race_StartTime = race1["raceStartTime"]
****
d1 = datetime.datetime.strptime(race_StartTime,"%Y-%m-%dT%H:%M:%S.%fZ")
new_format = "%H:%M"
HourOnly = "%H"
MinuteOnly = "%M"
Hour = str(int(d1.strftime(HourOnly))+11) # This is for Victoria AEDT (+11 hrs GMT)
Minute = d1.strftime(MinuteOnly)
race_StartTime = "Jump:" + Hour + ":" + Minute

raceStartTime = Label(inputFrame, text=str(race_StartTime), width=25, bg="darkblue", fg="white", font=("bold", 11), anchor=W)
raceStartTime.grid(row=0, column=20)

****


Cheers, this is the same reason i didn't add the time as yet because of time zones, but anyone could adjust this code to suit there own time zone, that issue i was having with the bug had to do with refreshing, the problem i had was when you change races it started another time refresh sequence, probably a simple fix when i work it out.

chook 10th November 2020 07:21 AM

cookbook
 
O'Reilley python cookbook 3 Beazley & Jones
advise using UTC for your time calcs and then moving to local timezone.

chapter 3.16, P 110 in third ed.

from datetime import datetime
#get your UTC date time
dt = datetime(2020,12,20,9,31,22)

from pytz import timezone
nsw = timezone( 'Australia/NSW' )
# = nsw.localize( your UTC date time )
ndt = nsw.localize( dt )

an alternative is to use Queensland time and check to see if you are in summer, by looking at your localtime.
i have done that before
or, move to Queensland

gsdanger 10th November 2020 03:38 PM

Tab_Prices - On your One Drive (Shaun)...
 
Hi Shaun,
Good to see you are progressing very well with the new python programming language.
You have made the python file available on your One Drive..That's great.!
My problem is that I cannot locate your One drive option here.(I had this problem a while ago, and you sent me a direct link to your drive, which allowed me to access the drive).
Can you please supply me with the link to your drive, so I can access the "TAB_Prices" file.

I am looking forward to using it and maybe assisting with enhancing it, although I am in the infancy of using the python language.

Please advise....Kind regards.

gsdanger

gsdanger 10th November 2020 10:20 PM

Tab_Prices - On your One Drive (Shaun)...
 
Hi Shaun,

Further to my last post...I managed to find a path to your One Drive...Hooray!

I assume the code needs to be downloaded and installed into the python area. (excuse my dumbness...).

Please advise.......Again please excuse my Dumbness....
Kind Regards....gsdanger


All times are GMT +10. The time now is 07:38 AM.

Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.