Skip to main content

Posts

I cannot edit the text within Tk.text as it keeps saying the function is not defined

I want to be able to have two functions, one function, get_text will allow me to retrieve the text currently in the text module and print it out. The other function set_text, I want to be able to replace the text currently in the tk.text with the input in the set_text function. #!/usr/bin/python3 import tkinter as tk import tkinter.ttk as ttk class GetMethodsTestApp: def __init__(self, master=None): # build ui global text1 toplevel1 = tk.Tk() if master is None else tk.Toplevel(master) toplevel1.configure(height=200, width=200) toplevel1.geometry("384x288") frame1 = ttk.Frame(toplevel1) frame1.configure(height=200, width=200) text1 = tk.Text(frame1) text1.configure(height=10, width=50) _text_ = 'result' text1.insert("0.0", _text_) text1.pack(side="top") frame1.grid(column=0, row=0, sticky="nsew") toplevel1.rowconfigure(0,

JS / Google Sheets optimal way of turning a "B2:H2" range to an array of cells

I'll be giving a bit of context: Using App script, I'm working on a macro which copies data from a sheet to another. To avoid copying mistakes cascading, I added code to check whether or not the cells are empty. There are 7 cells to check and the first or 5th one may be empty. (they either are both filled, or one of the 2 is blank, if the 2 are blank it's invalid), to simplify I made it so that the ranges are always continuous and on a single line, so only the columns change. To achieve my goal I did a simple counting loop: var rangeArray = rangeToArray(range); var emptyCells = 0; for (var o = 0; o < rangeArray.length; o++) { if (sheet.getRange(rangeArray[o]).isBlank()) { emptyCells ++; } } and only copy if the value of emptyCells is < 2 (it is presumming the cells they leave empty are the correct ones but I can't reasonably account for all human errors). (Please ignore the var, I tried using let, but for obscure reasons App Script doesn't support it)

Shopify: How To Change The Background Color Of The Product Page According To Different Variation?

I'm currently working on my product page, where all variation options are displayed on a single page. I would like to change the background color of the page based on the selected Flavor. For example, when one flavor is selected, the bg color changes smoothly to the flavor's picture bg color. Here's the link: https://www.yak9chews.com/collections/yak9-chews/products/test-all-chews-and-flavors?variant=4202493 I'm thinking the basic idea is to use a conditional structure like this: if (variation == variationNumber) { bgColor = "someColorHex"; } else if (variation == variationNumber1) { bgColor = "someColorHex2"; } else { // rest of conditions cases bgColor = default; } However, I'm not certain about this approach. I've been struggling with this issue for a month now and would appreciate any assistance. Thank you. Via Active questions tagged javascript - Stack Overflow https://ift.tt/a1MZYkI

Face recognition Python [closed]

We made this program it's a face recognition project for school and we are new to python, We've done a lot of research and we cam up with this. It works but it runs very slow, if someone can help us improve the speed of the program we would be very thankful! This is the code: import cv2 import os import face_recognition import glob known_faces = [] known_names = [] known_faces_paths = [] registered_faces_path = 'C:\\Users\\DELL\\Documents\\AttProj\\registered\\' for name in os.listdir(registered_faces_path): images_mask = '%s%s\\*.jpg' % (registered_faces_path, name) images_paths = glob.glob(images_mask) known_faces_paths += images_paths known_names += [name for x in images_paths] def get_encodings(img_path): image = face_recognition.load_image_file(img_path) encoding = face_recognition.face_encodings(image) if len(encoding) > 0: return encoding[0] else: return None known_faces = [get_encodings(img_path) f

Filtering by the result of an aggregate function

This is my dataframe: date id value 0 2002-01-07 PA12165 119.63 1 2002-03-13 PA12165 119.48 2 2002-05-13 PA12165 114.50 3 2002-06-12 PA12165 120.27 4 2002-06-12 PA12165 120.27 ... I want to get another dataframe by filtering by the result of an aggregate function. This is my attempt: my_aggs = {'id': 'count', 'value': [min, max, 'mean'] } df.groupby(['id', 'date']).agg(my_aggs).query('count > 1') raises: UndefinedVariableError: name 'count' is not defined As you can see I can't find the way to reference my aggregate function in the query source https://stackoverflow.com/questions/75784369/filtering-by-the-result-of-an-aggregate-function

Message doesn't get deleted in Discord but I dont get any error

On a discord bot I'm trying to continually clear some channels with the code below so that you can add channels and set a scheduled clear specified for it with time interval in hours or in minutes. So, when I type !cc channelid1 3h !cc channelid2 12h , it will add 2 separated channels to be cleared at their specific time When I do !start in Discord, I get Scheduled clear started . But no message is deleted and there is no error in output, terminal or logs The code is below. What did I do wrong? Something not logical ? in the code any other approach ? import discord import pytz from datetime import datetime, timedelta from discord.ext import commands, tasks intents = discord.Intents.all() bot = commands.Bot(command_prefix='!', intents=intents) channels_to_clear = {} # Dictionary of channel IDs and their clear frequencies hours_between_clears = 24 # The default number of hours between clearings is 24 hours channel_clear_frequencies = {} # Dictionary to store the c

Firestore onWrite() Doesnt Trigger if the Writer is a Python Script

I have an onWrite() firestore trigger defined like this: exports.onWriteTest = functions.firestore.document('test/{docId}').onWrite(async (snap, context) => { ... } This works fine when I write or update a document in the test collection using the Firestore UI. But if I write using a python script that should be doing the writing it wont get trigged. Here is the python script: data = {...} cred = credentials.Certificate(config_path) firebase_admin.initialize_app(cred) db = firestore.client() collection_ref = db.collection('test') for key, val in data.items(): collection_ref.document(str(key)).set(val) source https://stackoverflow.com/questions/75784364/firestore-onwrite-doesnt-trigger-if-the-writer-is-a-python-script