I have written a python script which displays all the live matches scores. I wish to display the score on my desktop rather than in terminal. I also wish to update the score card every 5 minutes or so.
Here is the python script:
import xml.etree.cElementTree as ET
import requests
tree = ET.fromstring(requests.get('http://www.cricbuzz.com/livecricketscore/home-score-matches.xml').text)
for elem in tree.iter('match'):
state = elem.find('state').text
footer = elem.find('footer').text
header = elem.find('header').text
print state,header,footer
xml file used for parsing
How can I achieve the above?
You will need to build a GUI for this. There are a lot of libraries that should help. A couple as example - PyQT4, Tkinter, easygui etc.
You don't need any fancy GUI stuff like Vikas Neha Suggested. All you need is pynotify library.
pynotify.init("TEST")
notice=pynotify.Notification("Your Score card",string_to_show)
notice.show()
This would Display your message onto the Bubble notification on your screen.
Related
for a project i have to make a GUI for python. It should show some variables (temp etc). But I don't know how I can pass variables trough GTK to the window. Any answers appreciated :)
some info: I am using a RPi3, but that's nothing which is important, or is it? I have a 7" display attached, on which the program should be seen in full screen. In the end, there should stand sth like temp, humidity, water etc
I don't exactly know which GTK i use, but it's in python. So I think it's pygtk
Thanks for reading,
Fabian
Done. I've used Flask, Socket.io and gtk to make an app, showing a html file in full screen, with python variables in it.
I'm a starting programmer looking to make a simple text based RPG from scratch. I know there might be an easy tool to do this but I want as little handed to me as possible to use this project as a sort of learning possible. I've been using Python and so far I really like it (I'm willing to use Java or Javascript if absolutely necessary.)
My problem though is that right now I'm using the console to run the game but I'd prefer to run it as a standalone application (also so I can distribute it in like an .exe or similar). Is there some simple way I can do this? Everything is in Unicode, so it just needs to be able to display Unicode text (in-line preferably) and have some way to check for key presses (to type commands).
I've looked into Kivy, but it seems far beyond what I need and the text it displays is not in-line and must be displayed line by line. Plus it doesn't seem to be able to be exported to a single file.
Thanks for the help and remember I'm very much a newbie.
If you want a GUI in Python, you can use TkInter, which is fairly easy to learn (https://wiki.python.org/moin/TkInter).
However, if you want to make it an executable so you can share it then you have to use something like the following:
cx_freeze (http://cx-freeze.sourceforge.net/)
py2exe(http://www.py2exe.org)
PyInstaller(http://www.pyinstaller.org)
These will 'freeze' your Python scripts by including the interpreter and libraries in the .exe file. There's a lot of information in this previously asked question; How do i convert a Python program to a runnable .exe Windows program?
Here's a basic example of a text thing in tkinter:
from tkinter import *
root = Tk()
playerEntry = Entry(root)
textLabel = Label(root, justify=LEFT)
playerEntry.pack()
textLabel.pack()
def changeText(addText):
textLabel.config(text = textLabel["text"] + addText + "\n")
def get(event):
changeText(">>> %s" % playerEntry.get())
do_stuff()
playerEntry.delete(0, END)
def do_stuff():
changeText("Stuff is happening")
playerEntry.bind("<Return>", get)
root.mainloop()
I want to automate one of my tasks, by changing a third-party GUI/MFC application's properties as per my requirements. Every time I need to carry out any testing, I need to change the properties of the application to test my software.
I tried to automate it by using Python and IronPython. After Googling a lot I found IronPython, because the GUI is written C# and VB.NET.
Suppose when opening the GUI in its editor it gives me the option to edit the properties, MFC contains lots of controls.. e.g.:
Enter Time |__| //Need to enter the value in the box
Enter the dealy |__| //Need to enter the value in the box
Want to display |_| //Check box , check or uncheck
some Radio buttons.
Some more controls.
....
....
I want to control all the changes from my Python script. I will just enter the value from my script and it will update them in the GUI.
I wrote a script in IronPython to read the GUI:
fw = open("MyFile.vnb", 'r')
for line in fw.readlines():
print (line)
I found plenty of encrypted/encoded characters along with some of the C#/VB.NET codes in the console. So, I am completely stuck here.
I would like to know can we edit a third-party GUI with Python/IronPython or not? Do I need to use some special tools from Python to edit the GUI?
If you need classic GUI automation you can control MFC application by pywinauto library. You can send keyboard events, mouse clicks, moves etc. pywinauto has also limited support for .NET controls (simple automation like buttons, text boxes etc. is available). I guess this is realistic task (see sample video by the link above).
But if you need some binary instrumentation to change the GUI executable permanently (it sounds strange), this is completely another topic. Read about PIN tool. It's used for profilers development, for example. Collecting stack samples, unwinding call stacks and other tricky reverse engineering things. :)
I just started up with python.I lately got a project where I have to make a powerpoint slideshow.This has to be done using leap motion sdk and python.So my powerpoint will be gesture based.
How do I deploy this on my desktop in
such a away that I just need to click on my desktop app or the ppt file itself, I get
started with the powerpoint like on windows.
I need to detect the finger gestures using python and integrate it
to next - previous functionality.
Can I get some guidance on powerpoint with PPT?
I have got the API,Documentation,SDK and I am learning python too.
The pywin32 library has a win32com.client module that lets you use COM API to control PowerPoint.
For example, this code will add a slide with an oval in it:
import win32com.client
Application = win32com.client.Dispatch("PowerPoint.Application")
Presentation = Application.Presentations.Add()
Base = Presentation.Slides.Add(1, 12)
oval = Base.Shapes.AddShape(9, 100, 100, 100, 100)
This IPython notebook has step-by-step examples on how to create a PowerPoint presentation, add objects to it, and make those objects interact in PowerPoint.
While this will allow you to use PowerPoint as an output interface, you need a different mechanism for sending messages back from PowerPoint to Python. One way is to set up a Macro that runs on a click event that interacts with a COM server set up in Python.
The documentation for this is not fantastic. However, using win32com and the PowerPoint API, you should be able to accomplish what you want to do.
The relevant commands are:
import win32com.client
import time
app = win32com.client.Dispatch("PowerPoint.Application")
presentation = app.Presentations.Open(FileName=u'C:\\path\\to\\mypresenation.pptx', ReadOnly=1)
presentation.SlideShowSettings.Run()
time.sleep(1)
presentation.SlideShowWindow.View.Next()
time.sleep(1)
presentation.SlideShowWindow.View.Next()
time.sleep(1)
presentation.SlideShowWindow.View.Previous()
time.sleep(1)
presentation.SlideShowWindow.View.Exit()
app.Quit()
Once you have a reference to the presentation, you can use this inside the code/functions where you handle the gestures.
you can some some pointers on what you want to do from this guy https://github.com/sanand0
look at his https://github.com/sanand0/pptx-git repo you should definitely get some pointers.
Hope this helps
You might be interested in the Google Slides API. I did some looking around and found this by far the best documentation and easiest setup with regards to python and doing a slide show. Here is a nice quick start guide...
https://developers.google.com/slides/quickstart/python?authuser=1
Use can use win32com
Here is code for slide show run, next, and back slide.
import win32com.client
import time
Application = win32com.client.Dispatch("PowerPoint.Application")
Presentation = Application.Presentations.Open("D:\\dataset\\slide.pptx")
print(Presentation.Name)
Presentation.SlideShowSettings.Run()
time.sleep(3)
Presentation.SlideShowWindow.View.Next()
time.sleep(3)
Presentation.SlideShowWindow.View.Next()
time.sleep(3)
Presentation.SlideShowWindow.View.Previous()
time.sleep(3)
Application.Quit()
Reference: https://github.com/tuantdang/SlideControlUsingBioSigal
I'm looking for a Python 3.x library that is able to allow interaction with other programs.
For example, I already have some sort of command-line interface which I have developed in python, and I
want to be able to enter, say "1", and have another program open. From here, I wish to hit another
input like "2" and have it manipulate the GUI that opens (for example, for it to "click" the Configurations
dropdown bar and select an option, perhaps modify a few settings, apply, and then possibly also automatically
enter some text). The reason I'm doing this is for test automation.
I've already tried using pywinauto, but I've found it to not be compatible for Python 3! :(
Is there another possible approach to this? Thanks in advance!!!
P.S. I may have forgotten to mention that I'm using Windows 7 but with Python32
You could look into sikuli. It lets you automate clicks and other actions based on region or matched graphic. Fairly smart. Is there a reason you're dead set on using py3?
Py3-compatible pywinauto released! New home page: http://pywinauto.github.io/
P.S. I'm maintainer of pywinauto.
Late answer, but have a look at pyautogui which enables you to move the mouse and press keys. I used it for the following snippet which launches an emulator and presses keys.
import pyautogui as pg
import os
import time
game_filepath = "../games/BalloonFight.zip"
os.system(f"fceux {game_filepath} &")
time.sleep(1)
keys_to_press = ['s', 's', 'enter']
for key_to_press in keys_to_press:
pg.keyDown(key_to_press)
pg.keyUp(key_to_press)
time.sleep(2)
im = pg.screenshot("./test.png", region=(0,0, 300, 400))
print(im)
A more detailed expalanation can be found here: Reinforcement learning to play Nintendo NES games
I created a pywinauto fork on GitHub that's compatible with Python 3:
https://github.com/Usonaki/sendkeys-py-si-python3
I only did basic testing, so there might still be some circular import related problems that I haven't found.