Is there any way to download/save all the images imported on the current stack?
Other question: I can't open the stack created by latest version 7.0 using the Livecode 6.6.2. Is there any workaround?
Other question: I can't open the stack created by latest version 7.0 using the Livecode 6.6.2. Is there any workaround?
In LC 7 under file menu select "Save as". In the following dialog you can select in which format you want to save the stack. Select "Legacy Livecode Stack (5.5)" and save it. The stack can now be opened with LC 5.5 and higher.
The following handler in a button will export all of the images on the current card to the Desktop:
on mouseUp
repeat with x = 1 to the number of images
put the short name of img x into tImgName
put img x into url ("binfile:/Users/asayd/Desktop/" & tImgName)
end repeat
end mouseUp
Of course, you can specify any directory as the save location. If you want to export all of the images in a stack just add another repeat loop outside the first one:
on mouseUp
repeat with y = 1 to the number of cards
go card y
repeat with x = 1 to the number of images
put the short name of img x into tImgName
put img x into url ("binfile:/Users/asayd/Desktop/" & tImgName)
end repeat
end repeat
end mouseUp
Related
I would like to take a picture using a webcam from excel macros, and I am a complete beginner when it comes to excel. I tried to follow other sources on the internet, but I can't even type in "Public Class Form1" without getting an error. What I did was I inserted a button into a spreadsheet, clicked "New," then replaced the sub data that comes with the button with code I found on the internet, and I just have tons of red lines throughout the code.
I looked at this post and its answers, but none of it works because, as I've said, excel doesn't want to work. If it's possible for you guys to give me more baby-step instructions (use this button and not that button, you gotta type "Public Class Form1" then pray to the gods for it to work instead of just pressing enter, stuff like that), that would help me greatly.
Visual Basic Connect to Webcam and Save Picture to File
Me not knowing how to terminate line. I tried &HD and &HA since that's a solution from microsoft, but that obviously didn't work.
The answer is don't try to do the whole thing from excel. In excel, assign a macro to a button. The code in that macro will be:
Sub RunPython()
Dim objShell As Object
Dim PythonExe, PythonScript As String
Set objShell = VBA.CreateObject("Wscript.Shell")
PythonExe = """PATH TO PYTHON.EXE"""
PythonScript = "PATH TO PYTHON CODE THAT NEEDS TO BE RUN"
objShell.Run PythonExe & PythonScript
End Sub
In Python 3, you, use the following code:
from cv2 import *
cam = VideoCapture(0) # 0 -> index of camera
s, img = cam.read()
if s: # frame captured without any errors
namedWindow("cam-test", WINDOW_NORMAL)
imshow("cam-test",img)
waitKey(1000)
destroyWindow("cam-test")
imwrite("filename.jpg",img) #save image
Credit:
Using Excel to use Python: https://stackoverflow.com/a/60658227/9582521
Using Python to use Webcam: https://stackoverflow.com/a/11094891/9582521
I have a little python app that searches the file system for files, and lets you drag them out of a QListWidget and into other software, your desktop, etc.
The problem is, I don't ever want to destroy/remove the source file. If I drag the file onto my desktop, I want to keep the file in the source location as well.
Currently, I'm creating a QDrag event and attaching mime data for the file. How do I tell windows that this is a copy/paste situation rather than a cut/paste situation?
class MyListWidget(QListWidget):
...
def dragLeaveEvent(self, event):
global window
drag = QDrag(self)
data = QMimeData()
data.setData("text/plain", "")
files = []
# Loop through QList (file paths), turn into QUrl, and add to array
for element in window.searchResults.selectedIndexes():
url = element.data()
files.append(QUrl.fromLocalFile(url)
data.setUrls(files)
drag.setMimeData(data)
drag.exec_()
As #musicamante suggested, changing drag.exec_() to drag.exec_(QtCore.Qt.CopyAction) did the trick!
I want to download each state's legislative upper chamber zip file from this url.
https://www.census.gov/cgi-bin/geo/shapefiles/index.php?year=2016&layergroup=State+Legislative+Districts
First, I want automatically download these hundreds of files to save time and effort.
Second, I want to save these legislative upper chamber zip files in the following format: us_state[0:]_upper_chamber_tl_2016_01_sldu_zip
Here is the link to the code that I so far have come up written. https://bpaste.net/show/9514161688ea
Thank you in advance for your feedback.
import pyautogui
#Step 1 Move to click on the drop down list of State Legislative - Upper
#Chamber
uc = pyautogui.moveTo(1403, 671, duration=1.5)
pyautogui.click()
#Step 2 Move to click on the state in the drop down list.
al_uc = pyautogui.moveTo(1403, 700, duration=0.5)
pyautogui.click()
#Step 3 Move to the down download button
uc_dl = pyautogui.moveTo(1541, 679, duration=1)
pyautogui.click()
For those who are working with Python, I was suggested to use the "pyautogui" module. One needs to program where to click.
I encountered two problems.
(1) I had the automatic downloader in Chrome on. So, I had to turn it off so that it would not allow my downloads to pop up after downloading and messing with the code.
(2) I reduced the mouse duration speed from 0.5 to 1.5 when going to my target list from the download button. I did so because of my slow internet connection, chrome being slow at downloading, refreshing, and messing with the code.
Link to install pyautogui:
http://pyautogui.readthedocs.io/en/latest/install.html
In the documentation for fileDialog2 (http://download.autodesk.com/us/maya/2011help/pymel/generated/functions/pymel.core.system/pymel.core.system.fileDialog2.html), it says acceptMode (am) can be set to 0 or 1 to tell it if it should be opening or saving images.
However, upon setting this to 0 or 1, nothing actually happens and None is returned, and just leaving it empty will result in save dialog box. I'm currently using fileDialog to get around the problem, but it's an earlier version without as much functionality, and when one newer function should cover both, it seems pointless having to use an old one at the same time.
Here's a quick example of what to do:
import pymel.core as pm
pm.fileDialog2()
#brings up a save file window
pm.fileDialog2( am = 1 )
pm.fileDialog2( acceptMode = 0 )
#nothing happens
Also, using help(pm.fileDialog2) just comes up with help for NoneType or list depending on if a file is selected or not.
You need to specify the fileMode option:
import pymel.core as pm
test = pm.fileDialog2(fileMode=1)
print test
Basically I want to create type of quiz in Python 3.4 with EasyGui using multiple images on the button boxes.
How I'd imagine it'd work would be like this:
import easygui as eg
# A welcome message
eg.msgbox ("Welcome to the quiz", "Quiz!")
# A short splash screen this could be looped
Finish = "Start"
while Finish == "Start":
Finish = eg.buttonbox("Do you want to start the quiz or quit?","Welcome",["Start","Quit"])
if Finish == "Quit":
break
#Question 1
image = "mickey.gif"
choices = ["Mickey","Minnie","Daffy Duck","Dave"]
reply=eg.buttonbox("Who is this?",image = image,choices = choices)
if reply == "Mickey":
eg.msgbox("Well done!","Correct")
else:
eg.msgbox("Wrong","Failure")
This works, but if I change the line
reply=eg.buttonbox("Who is this?",image=[image,image2,image3,image4],choices = choices)
But that doesn't seem to work, does anyone know if you can have more than one image per buttonbox?
at the current version of easygui, you can't have multiple images, only one image.
You could either:
use an external tool to create one big merged image out of several smaller images.
try to make the necessary changes direct inside easygui.py (it's all in one single file) if you have knowledge in tkinter
help / contact Robert Lugg as he works on an improved version of easygui https://github.com/robertlugg/easygui
allpic = ("image", "image2", "image3")
reply=eg.buttonbox("Who is this?",image=allpic,choices = choices)