I am trying to build a pygame editor with python and tkinter.
I have this situation: on a tkinter canvas I can place tiles neatly and without overlapping (see attached image, tiles are taken from Ghosts 'n Goblins).
Now I would like to export what is displayed on the canvas to a csv file:
for instance, if in a particular cell there's no image I would like to export "-1" to the csv file;
if in the cell nearby there's an image (let's say 1.png) I would like to export "1" to the csv;
if the image displayed is "2.png" I would like to export "2" and so on.
I am able to open a csv file and write on it but I cannot retrieve the information I need from Tkinter.
I think I could use some kind of a for loop but I do not know where to start.
I've tried:
img_on_grid = []
def export_csv():
for row in range(8):
test_1=canvas.itemcget("image_B", "image")
img_on_grid.append(test_1)
print(img_on_grid)de here
but it doesn't work: it repeats the id item.
Any help will be appreciated.
Related
I'm trying to replicate this example from the dash-leaflet documentation, but for world countries instead of US states. However, when I run the code from the documentation on my machine I don't see the blue state borders in the output visual.
I figured this was because I don't have the right geojson data locally, so I downloaded some country border GeoJSON data from here but it's unclear to me how to get the dl.GeoJSON function to make use of that data. How can I get country borders to show up on the world map in the same way the states do in the linked example?
You should set the url property of the GeoJSON component to point to the data that you want to visualize. For all countries as shown in your link, the code would be along the lines of
import dash_leaflet as dl
from dash import Dash
# An url pointing to the data that you want to show.
url = "https://pkgstore.datahub.io/core/geo-countries/countries/archive/23f420f929e0e09c39d916b8aaa166fb/countries.geojson"
# Create example app.
app = Dash()
app.layout = dl.Map(children=[dl.TileLayer(), dl.GeoJSON(url=url)],
style={'width': '100%', 'height': '50vh', 'margin': "auto", "display": "block"})
if __name__ == '__main__':
app.run_server()
I'm creating a data infographic in Photoshop that inputs 'strengths / weaknesses' from a .csv file in Excel. The only thing I'd like to have is the bars that signal strength/weaknesses to adjust to the data in the csv (e.g. get longer/shorter).
To make it more clear-
Student test scores > .csv file > .psd graphic variables > if A1 = >80%, A1 psd graphic is bigger.
Essentially, I don't want to have to use illustrator to actually 'animate' the graphics. I'm wondering if there's an easier way to have flexible moving graphics per every different .csv data variable.
Would it be easier to just set each graphic itself as a pixel variable that changes? I'm hoping not. Solutions? Anyone have a script for something like this?
A script would be the best answer to your task, if you want to avoid a photoshop variable per pixel graphic.
I am mostly experienced with variable data using Illustrator, but I believe same can be accomplished with photoshop. In your case, variables would be wholly unnecessary, as you'll simply need a script which changes the drawing of your artwork based on CSV data. For example, you can have pixel or path layers named by column headers, and the script would draw or change the path shape according to the data. To get help with such a custom script, you may reach out in the Adobe Scripting forums.
I have a pandas data frame , which I am trying to render as a PDF using Weasyprint. For other formatting changes , I have used 'column formatters' and modified the underlying HTML.
int_frmt = lambda x: '<div style="text-align:right">%s</div>' % '{0}'.format(int(round(x)))
frmt = {col: int_frmt for col in df.columns if df.dtypes[col] in [np.dtype('int64'), np.dtype('float64')]}
How can I add a Heatmap to the PDF in the same manner ( by modifying the underlying HTML )?
One way of doing this, which I could think, is to generate a separate pandas dataframe which contains all the color information, and then superimpose the two frames by iterating over all the values and modifying each cell individually.
I am looking for a more direct and comprehensive solution, or an API, of the like we have in Matplotlib, Seaborn ( heatmap() function ).
Thanks a lot.
How to load captured image from a location into sikuli script and make it clickable.
here is what I am doing:
open pp
capture desired image
save it to some location
Now I want to load that captured image and make it clickable in code, so that functions in that carpeted image can be used as needed.
please assist... Or any work around will be much appreciated.
My Code
openApp('Safari') App.focus("Safari")
wait(10)
import shutil
import os
dir = "imgpath" wait(5)
image = capture()
name = input("abc")
newimg = os.path.join(dir, name + ".png")
shutil.move(image, newimg)
I just tried to use Google Map Buddy to get satellite image from Google Map. This application first download small images from google map and then stick them together into new image. I had to wait about 2 hours to get images download my computer and it looks like it downloaded all images (22,194 images) but then the app told me that it cannot stick them together. When I started app again I though this app will reuse images on my comp but it start downloading them again. So I had to stop the process and ask you, guys, if you know how I can put that puzzle together.
The naming pattern of those images goes like this:
x=92651y=48130zoom=17.png
x=92652y=48130zoom=17.png
x=92653y=48130zoom=17.png
x=92654y=48130zoom=17.png
x=92655y=48130zoom=17.png
...
...
x=92664y=48131zoom=17.png
x=92665y=48131zoom=17.png
x=92666y=48131zoom=17.png
x=92667y=48131zoom=17.png
...
...
x=92689y=48132zoom=17.png
x=92690y=48132zoom=17.png
x=92691y=48132zoom=17.png
x=92692y=48132zoom=17.png
x=92693y=48132zoom=17.png
What can I do to stick them together programmatically using some simple scripting language? I have access to Mac and Windows systems and may be can install any simple scripting languages.
Thanks
You could use Python with Python Imaging Library (PIL).
First I'd make a list of filename and their coordinates. Extract the integer coordinates from the filenames with regular expressions and store them in a list of dictionaries:
>>> filename = 'x=92664y=48131zoom=17.png'
>>> imagePattern = re.compile(r'^x=(\d{5})y=(\d{5})zoom=17.png$')
>>> x,y = map(int, imagePattern.search(filename).groups())
>>> {'x':x, 'y':y, 'filename':filename}
{'y': 48131, 'x': 92664, 'filename': 'x=92664y=48131zoom=17.png'}
Having a list of dictionaries enables you to sort them according to either dimensions:
tileListSortedByX = sorted(tileList, key = lambda i: i["x"])
and also filter them:
fileListWhereX48131 = [tile for tile in tileList if tile["x"]==48131]
With these two operations you can easily imagine the for loops to iterate over tiles line by line.
The last thing you need to create a big empty image (with PIL) where you'll paste the small tile images into. Its size will be a multiple of the tile size.
>>> from PIL import Image
>>> bigImage = Image.new('RGB',(300,300),(255,255,255))
#creates a white 300x300 image
Pasting the small images into the big one looks like this:
>>> smallImage = Image.open(tile["filename"])
>>> bigImage.paste(smallImage,(0,0))
Hope you get the idea.
The process of "sticking images together" is usually called "stitching" or "mosaicing".
I found a list of many applications that do this on Wikipedia article - "Comparison of Photo Stitching Applications".
Edited: removed link to single app I found and replaced with wikipedia list of software.