For loop python - by year and groupby operation Posted: 19 Dec 2021 12:28 PM PST New here. I have rainfall data that shows seasonal totals from 1990-2011 for 24 rain gauges (i.e.'RG1, 'RG2'). I did a spatial join to associate each rain gauge with the watershed it's in. I'm interested in looking at these yearly - I did one for 2008, where it shows me the season rainfall totals for each watershed. How do I write a for loop that iterates over the data for each year (1990-2011) and puts it all in one dataframe? Any help is appreciated - thank you! year2008s = rainfall_watershed.loc[rainfall_watershed['year']=='2008'].groupby('WATERSHED_NAME', as_index=False)['inches'].mean() |
how to pass button value from custom widget to main application in tkinter when clicked Posted: 19 Dec 2021 12:28 PM PST I have created a custom widget for tkinter that lays out 5 buttons. The widget works beautifully for the most part. The problem is that I cannot figure out how to pass the button that the user presses in the widget to the main application. The custom widget stores the last button pressed in a variable, but I cannot figure out how to make the main application see that it has been changed without resorting to binding a button release event to root. I would like to try to build out this custom widget further, and I want it to work without having to do some messy hacks. Ideally, in the example below, when a button is pressed, the label should change to reflect the button pressed. For example, if the user clicks the "2" button, the label should change to "2 X 2 = 4". How can I pass the text on the button directly to the main application for use? Hopefully, I am making it clear enough. I want to be able to get the value from the widget just like any other tkinter widget using a .get() method. Here is the code that I am using: import tkinter as tk from tkinter import ttk class ButtonBar(tk.Frame): def __init__(self, parent, width=5, btnLabels=''): tk.Frame.__init__(self, parent) self.btnLabels = [] self.btnNames = [] self.setLabels(btnLabels) self.selButton = None self.display() def getPressedBtn(self,t): """ This method will return the text on the button. """ self.selButton = t print(t) def createBtnNames(self): """ This method will create the button names for each button. The button name will be returned when getPressedBtn() is called. """ for i in range(0,5): self.btnNames.append(self.btnLabels[i]) def display(self): """ This method is called after all options have been set. It will display the ButtonBar instance. """ self.clear() for i in range(len(self.btnLabels)): self.btn = ttk.Button(self, text=self.btnLabels[i], command=lambda t=self.btnNames[i]: self.getPressedBtn(t)) self.btn.grid(row=0, column=i) def setLabels(self, labelList): if labelList == '': self.btnLabels = ['1', '2', '3', '4', '5'] self.createBtnNames() else: btnLabelStr = list(map(str, labelList)) labelsLen = len(btnLabelStr) def clear(self): """ This method clears the ButtonBar of its data. """ for item in self.winfo_children(): item.destroy() root = tk.Tk() def getButtonClicked(event): global selBtn print(event) if example.winfo_exists(): selBtn = example.selButton answer = int(selBtn) * 2 myLabel.config(text='2 X ' + selBtn + ' = ' + str(answer)) tabLayout = ttk.Notebook(root) tabLayout.pack(fill='both') vmTab = tk.Frame(tabLayout) myLabel = tk.Label(vmTab, text='2 X 0 = 0', width=50, height=10) myLabel.pack() vmTab.pack(fill='both') tabLayout.add(vmTab, text='Volume Movers') # Create the ButtonBar. example = ButtonBar(vmTab) selBtn = None example.pack() lbl = tk.Label(root, text='') root.mainloop() I have looked at some other posts on stackoverflow. This one creating a custom widget in tkinter was very helpful, but it didn't address the button issue. I though this Subclassing with Tkinter might help. I didn't understand the If I bind the event using root.bind("<ButtonRelease-1>", getButtonClicked) , then the widget works fine. Is there any other way to do it though? |
Preview images or documents in my own gui after finding several results and thus several paths Posted: 19 Dec 2021 12:27 PM PST I'm new at python and I'm making a search engine of sorts. I've got to the point where I made an array containing the search results and their respective paths (all in the same directory for simplicity). How do I display their thumbnail like you would on a file explorer after searching for something? I know I can add an os.startfile(path, 'open') to open each result but I wanted to display it in a list with a thumbnail first so the User can pick the best result without having to open all the files. |
Argument type 'Function' can't be assigned to the parameter type 'void' Posted: 19 Dec 2021 12:27 PM PST I am passing a call back function from my child file to the parent file, in the elevated button class, I am passing the function in the class (in the child file )to the named parameter on pressed, but I am getting the error in the question above, while it worked for the tutorial I am using(academind). How do I solve this? |
inserting blob data in Java, MySQL Posted: 19 Dec 2021 12:27 PM PST I am using the following code to insert an image in my database. But I get error when trying to save selected image file as blob type. The error is, java.lang.ClassCastException: class java.io.FileInputStream cannot be cast to class java.sql.Blob (java.io.FileInputStream is in module java.base of loader 'bootstrap'; java.sql.Blob is in module java.sql of loader 'platform') at app.register$10.actionPerformed(register.java:468) enter image description here problem is here enter image description here newUser function and user.picture is Blob variable. How can I fix this problem? |
C++ || How Can I Listing Files/Directorys in a drive (like : C:\\ etc..) optimally/quickly Posted: 19 Dec 2021 12:27 PM PST I want to list all the files on a computer. Even on multiple drives, if the computer has multiple drives. Cloud does not have to be included, just the local files. I have tried recursive_directory_iterator from 'filesystem' (C++17). But that code is SO slow. Maybe it's not written optimally. So can someone help me on how to do this relatively quickly. It has to be able to store the file path in a string one at a time so the program can work with the file and when it's finished with that file, the next overwrites the string. It doesn't have to display the path like in the example provided, but it's good if it can. The code: for (auto& p : std::filesystem::recursive_directory_iterator("C:\\")) { std::cout << p.path() << '\n'; } When I ran this, it worked. I have around 450GB of data on my C: drive and lots of folders, and in around 8 minutes it still was 1/3 done or probably less. The program has to be run as an administrator unless it will trip up at certain folders/files. But that's not a problem. |
Mocking PutSubscriptionFilter with botocore.Stubber or moto Posted: 19 Dec 2021 12:27 PM PST This isn't specific to my code at all. I've tried using botocore.Stubber and moto to mock a boto3.client('logs') call with the 'put_subscription_filter' method and I get: botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the PutSubscriptionFilter operation: The specified log group does not exist The issue is that fundamentally, of course no log groups are going to exist against a mock call. I even ran a mock "describe_log_groups" call and of course, there's nothing. How can I test PutSubscriptionFilter when no log groups exist in a mock call to begin with? |
Flutter How to validate uniqe username? Posted: 19 Dec 2021 12:26 PM PST I am trying to validate uniqe username for SignUp Page. Here is my TextFormField code: TextFormField( onSaved: (deger) => _username = deger!, textInputAction: TextInputAction.done, keyboardType: TextInputType.name, controller: usernameController, decoration: const InputDecoration( suffixIcon: Icon(Icons.person), label: Text("username"), ), ), Here is my Button: ElevatedButton( onPressed: () async { final valid = await _checkUserName( usernameController.text); if (valid!) { Get.snackbar( "hata", "username exist"); } else if (formKey.currentState!.validate()) { formKey.currentState!.save(); //myAuthController codes here it doesnt metter. } else { debugPrint("error"); } }, child: const Text("SIGNUP"), ), My function for validate existed username in Firestore: Future<bool?> _checkKullaniciAdi(String username) async { final result = await FirebaseFirestore.instance .collection("customer") .where('username', isEqualTo: username) .get(); return result.docs.isEmpty; } This codes are always returning Get.snackbar("hata", "username exist"); What can I do ? |
Postgresql :joining on fields using CASE statement Posted: 19 Dec 2021 12:26 PM PST I am trying to join two tables on two fields with a below condition If condition 1 is satisfied then join ON a.field_1 = b.field_1 If condition 2 is satisfied then join ON a.field_2 = b.field_2 In order to do so, I am writing the below query SELECT a.field_1,a.field_2, b.field_1,b.field_2 FROM table a INNER JOIN table b CASE WHEN COALESCE(TRIM(a.field_1),'') = '' THEN a.field_1 = b.field_1 ELSE a.field_2 = b.field_2 END I am not sure whether this would run. Please suggest. |
Tkinter timer not being able to detect ending Posted: 19 Dec 2021 12:25 PM PST I am trying to make a tkinter clock with a timer and I have almost got it done however I still cannot figure out how to detect when the timer is over. I have tried something like this: TimeOver = Label(root, text = Time Over) def Update(): if TimerVar < 0: #TimerVar is how much time is left TimeOver.pack() root.after(1000, Update) Update() However, that doesn't work. (I've just learned while true loops ruin it) I've also tried this: while True: if TimerVar < 0: #TimerVar is how much time is left TimerOver.pack() And again that just stop's it from working. My real code is: from tkinter import * import time from datetime import date from datetime import datetime global CountDownTime global TimerOn CountDownTime = 0 TimerOn = False root = Tk() root.title("Alarm Clock") root.geometry("500x500") TimerVar = 0 Time = Label(root, text = f"{time}", font = ("Times New Roman", 50)) Time.place(x = "160", y = "100") Timer = Label(root, text = f"{TimerVar}") def TimerUpdate(): global TimerVar TimerVar = TimerVar - 1 Timer.config(text = f"{TimerVar}") root.after(1000, TimerUpdate) def Update(): global TimerOn global CountDownTime now = datetime.now() time = now.strftime("%H:%M:%S") Time.config(text = f"{time}") if TimerOn == True: root.after(1000, TimerUpdate) TimerOn = False root.after(1000, Update) def AppendTime(): global TimerVar TimerVar = TimerVar + 60 Timer.config(text = f"{TimerVar}") def DeductTime(): global TimerVar TimerVar = TimerVar - 60 Timer.config(text = f"{TimerVar}") HigherTimer = Button(root, text = "+", command = AppendTime, font = ("Times New Roman", 25)) LowerTimer = Button(root, text = "-", command = DeductTime, font = ("Times New Roman", 25)) def Start(): global TimerOn Timer.config(font = ("Times New Roman", 50)) Timer.place(x = "160", y = "250") TimerOn = True CountDownTime = TimerVar * 1000 def CreateTimer(): HigherTimer.pack() Timer.pack() LowerTimer.pack() StartTimer.pack() Time.place(x = "160", y = "150") StartTimer = Button(root, text = "Start", command = Start, font = ("Times New Roman", 25)) createTimer = Button(root, text = "Set a timer", command = CreateTimer) createTimer.pack() Update() root.mainloop() #root.update() |
How to replace the enumerate with a string input? Posted: 19 Dec 2021 12:27 PM PST import itertools for outcomes in itertools.product("ABC", repeat=5): print("PERSON", "OUTCOME") for person, outcome in enumerate(outcomes, start=1): print(str(person).ljust(6), outcome.ljust(6)) I want my output to be: PERSON OUTCOME Hannah A Esther B Philo C Anna A |
Python typing allow object of a certain class in the __init__ of that same class Posted: 19 Dec 2021 12:27 PM PST I am trying to create a class called Theme whose __init__ function allows another object, which may be of type Theme , to be passed in. But when I try and type hint that an object of that type is allowed, Python throws an error because Theme is not yet defined. Here is the code, which works when I take out the type hint: from typing import Union class Theme: def __init__(self, start: Union[dict, Theme, None] = None): if start is None: start = {} elif isinstance(start, Theme): start = start.dict self.dict = start The error I am getting is: Traceback (most recent call last): File "C:/Users/.../Test.py", line 4, in <module> class Theme: File "C:/Users/.../Test.py", line 6, in Theme def __init__(self, start: Union[dict, Theme, None] = None): NameError: name 'Theme' is not defined Is there any way I can achieve this or is it just not possible and I shouldn't bother? |
RegEx in VSCode: capture every character/letter - not just ASCII Posted: 19 Dec 2021 12:25 PM PST I am working with historical text and I want to reformat it with RegEx. Problem is: There are lots of special characters (that is: letters) in the text that are not matched by RegEx character classes like [a-z] / [A-Z] or \w . For example I want to match the dot (and only the dot) in the following line: Quomodo restituendus locus Demosth. Olÿnth Without the ÿ I could easily work with the mentioned character classes, like: (?<=(<tag1>(\w|\s)*))\.(?=((\w|\s)*</tag1>)) But it does not work with special characters that are not covered by ASCII. I tried lots of things but I can't make it work so the RegEx really only captures the dot in this very line. If I use more general Expressions like (.)* (instead of (\w|\s)* ) I get many more of the dots in the document (for example dots that are not between an opening and a closing tag but in between two such tagsets), which is not what I want. Any ideas for an expression that covers like all unicode letters? |
how can i copy string from file to a linked list in C? Posted: 19 Dec 2021 12:27 PM PST Hi guys i can't copy text from a file to linked list, with integers there is no problem. There is my code. Main problem is to copy year of visit and name of city to a linked list like, I'm new in programming and tbh i can't get a lot of things. Pointers seems very hard to me #include <stdio.h> #include <stdlib.h> #define K 50 typedef struct tourists{ int year; char city[K]; char country[K]; struct tourists *next; }Element; typedef Element *List; List from_file_to_list(char file_name[20]) { FILE *file1; int x, y; char city_name[K]; List temp, head = NULL; file1 = fopen(file_name, "r"); if(file1 == NULL) { printf("Cannot do that"); return NULL; } while(fscanf(file1, "%d %s", &x, city_name) != EOF) { temp = (List)malloc(sizeof(Element)); temp->city[K] = city_name; temp->year = x; temp->next = head; head = temp; } return head; } void show_list(List head) { List temp; temp = head; while(temp != NULL) { printf("%s", temp->city); temp = temp->next; } } int main() { List head = NULL; head = from_file_to_list("from.txt");` show_list(head); } |
Anyway to optimize a large (127K) reading english words txt file Posted: 19 Dec 2021 12:29 PM PST This is my function: public void addToList() throws IOException { String urlString = "http://web.stanford.edu/class/archive/cs/cs106l/cs106l.1102/assignments/dictionary.txt"; URL url = new URL(urlString); Scanner scannerWords = new Scanner(url.openStream()); while (scannerWords.hasNextLine()) { words.add(scannerWords.nextLine()); } } Which takes: 32.8 sec runtime to get executed. Anyway I can optimize it (maybe read every 10 lines)? |
Use Selenium to get input element value, if it isn't in HTML? Posted: 19 Dec 2021 12:27 PM PST Is there any way to read the text in an input without calling to get it from HTML? In the image, I want to get whatever value I can from the input, store it, then add a number to it, but it's not in the HTML(the input just refers to "quantity" Is there some way I could select the input box, copy the value, then interact with the value from there? |
Cumulative tiered rate calculation in SQL Server for DML UPDATE/INSERT trigger? Posted: 19 Dec 2021 12:28 PM PST Essentially, using SQL Server, I want to take the "Gross Amt" from the current table below (which is derived from a computed column upon INSERT or UPDATE ) and then have that "Gross Amt" run through the "Tiered Table" to derive the "Total A $" in the desired output table. I figured this would likely need to be done with a trigger (maybe a function?) since this calculation would happen upon INSERT or UPDATE and because the conditional logic could be incorporated into it since there are different tier tables with different Min/Max values and percentage thresholds for different tiers. The example below is, of course, cumulative, and functions like marginal income tax rates, the first 10000 is at 90% (for Total A), the second tier calculates the 19999 at 60%, the third 69999 at 40%, and so on, etc. There are other regions with different tiers that are just simple lookup reference values. Tiered table: RegionID | TierNo | Min | Max | Total A | Total B | 3 | 1 | 0 | 10000 | .90 | .10 | 3 | 2 | 10001 | 30000 | .60 | .40 | 3 | 3 | 30001 | 100000 | .40 | .60 | 3 | 4 | 100001 | 500000 | .40 | .60 | 3 | 5 | 500001 | 999999999999 | .20 | .80 | Current table sample: TransID | RegionID | GrossAmt | Total A % | Total A $ | Net Amt | 100001 | 3 | 125000 | | | | Desired output: TransID | RegionID | GrossAmt | Total A % | Total A $ | Net Amt | 100001 | 3 | 125000 | 0.47 | 59000 | 66000 | Any ideas or guidance would be extremely helpful and appreciated. |
looping two columns when their time is close to each other by a given threshold value Posted: 19 Dec 2021 12:27 PM PST I have two columns in a dataframe named [Timeline and Start] and their type is a timestamp. I want to write a function that can set a threshold value = 30 seconds, and if the time in the start column is close to any value in the time of the Timeline column by the threshold value, this value from the start column will be moved under the Timeline column. For example, insert 00:58:26 under 00:11:27 in the same start column if they have the difference in time of the threshold value. My code which I tried can only find time similarities as objects, which is not the required task. threshold = 0.8 from difflib import SequenceMatcher def similar(a, b): return SequenceMatcher(None, a, b).ratio() result_1 = pd.DataFrame(columns = ["Timeline", "Start"]) for i, r1 in df1.iterrows(): for j, r2 in df2.iterrows(): if similar(r1["Timeline"], r2["Start"]) > threshold: result_1.loc[len(result_1.index)] = [r1["Timeline"], r2["Start"]] print(result_1) |
Timestamp string conversion / from_utc_timestamp Posted: 19 Dec 2021 12:25 PM PST I need to convert 2021-10-03 15:10:00.0 as 2021-10-03T15:10:00-04:00 I tried with. from_utc_timestamp(from_unixtime(unix_timestamp('2021-10-03 15:10:00.0', "yyyy-MM-dd HH:mm:ss.S"),"yyyy-MM-dd'T'HH:mm:ssXXX"),"America/New_York") I got Null value Any suggestions please |
google app script trying to access post data on web app via do post Posted: 19 Dec 2021 12:27 PM PST I need to access formIDArray but in appscript return nothing when i call that. And how can i access this object ("FormIDArray[]") from the appscript |
Correctly dynamic loading PIEs Posted: 19 Dec 2021 12:25 PM PST Many discussions like this and this have warned us with examples that trying to dlopen a PIE could never be correct. The reasons are various: copy relocations, TLS, etc. However, these problems can be circumvented if we loose the restriction. This question showed us compiling with fPIC can eliminate copy relocation, and TLS seems to work alright. This brings up the question about how far we are from correctly dynamic loading a PIE. I agree with the idea again in link 1: Bottom line: this was never designed to work, and you just happened to not step on many of the land-mines, so you thought it is working, when in fact you were exercising undefined behavior. But I'm more interesting about WHY we could not do that, instead of another failing example. More specifically, users could write their own runtime dynamic linker as this comment suggest, which could make some strong assumptions or compromises just for this purpose. Yet this requires extremely broad knowledge on compiling, linking and loading, some of which are known to be poorly documented. So again, how do users correctly dynamic load PIEs, or at least how can they try to find a way to do that(or not to do that)? |
How do I resolve "Cannot find connection in scope" error (SQLite)? Posted: 19 Dec 2021 12:27 PM PST I'm trying to use sqlite.swift in a small app I'm developing, but I'm new to Swift and SQLite. I used CocoaPods to install sqlite.swift. I used these commands: sudo gem install cocoapods pod setup --verbose I then navigated to the directory for my app and entered: pod init open -a Xcode Podfile I then edited the pod as follows: platform :ios, '9.0' target 'GeneralPractice (iOS)' do pod 'SQLite.swift', '~> 0.13.1' end I then open the app workspace and add import sqlite3 to ContentView.swift , and then add this code before struct ContentView: View { : let path = NSSearchPathForDirectoriesInDomains( .documentDirectory, .userDomainMask, true ).first! let db = try Connection("\(path)/db.sqlite3") When I run the app, I get this error: "Cannot find 'Connection' in scope" Given how new I am to this and to Swift, I suspect I'm making some simple error, but any help resolving this would be very much appreciated. |
Can the input take up as much space as needed? Posted: 19 Dec 2021 12:27 PM PST <table class="grid-view" rules="cols" id="MainContent_GridViewMüşteri" style="color:Black;background-color:White;border-color:#DEDFDE;border-width:1px;border-style:None;border-collapse:collapse;" cellspacing="0" cellpadding="4"> <tbody><tr style="color:White;background-color:#333333;font-weight:bold;"> <th scope="col"> </th><th scope="col"><a href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Sort$Ünvan')" style="color:White;">Ünvan</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Sort$İsim')" style="color:White;">İsim</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Sort$Soyisim')" style="color:White;">Soyisim</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Sort$TelefonNo')" style="color:White;">TelefonNo</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Sort$ePosta')" style="color:White;">ePosta</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Sort$GörüşmeZamanı')" style="color:White;">GörüşmeZamanı</a></th><th scope="col"> </th><th scope="col"> </th> </tr><tr style="background-color:#F7F7DE;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$0')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0507 424 53 35</td><td> </td><th scope="row">11/29/2021 1:37:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$0')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$0')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:White;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$1')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0507 494 53 35</td><td> </td><th scope="row">11/29/2021 1:37:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$1')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$1')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:#F7F7DE;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$2')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0507 494 56 35</td><td> </td><th scope="row">11/29/2021 1:37:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$2')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$2')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:White;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$3')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0555 155 55 55</td><td> </td><th scope="row">12/18/2021 2:52:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$3')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$3')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:#F7F7DE;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$4')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0555 255 55 55</td><td> </td><th scope="row">12/18/2021 2:52:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$4')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$4')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:White;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$5')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0555 505 55 55</td><td> </td><th scope="row">12/18/2021 2:52:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$5')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$5')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:#F7F7DE;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$6')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0555 515 55 55</td><td> </td><th scope="row">12/18/2021 2:52:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$6')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$6')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:White;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$7')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0555 525 55 55</td><td> </td><th scope="row">12/18/2021 2:52:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$7')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$7')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:#F7F7DE;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$8')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0555 550 55 55</td><td> </td><th scope="row">12/18/2021 2:52:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$8')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$8')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:White;"> <td><a class="btn btn-info" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Select$9')" style="color:Black;font-weight:bold;">Seç</a></td><td>Dr.</td><td>Osman</td><td>Baykuş</td><td>0555 551 55 55</td><td> </td><th scope="row">12/18/2021 2:52:00 AM</th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Edit$9')" style="color:Black;font-weight:bold;">Düzenle</a></td><td><a class="btn btn-danger" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Delete$9')" style="color:Black;font-weight:bold;">Sil</a></td> </tr><tr style="background-color:#F7F7DE;"> <td></td><td><input name="ctl00$MainContent$GridViewMüşteri$ctl12$ctl00" type="text" value="Prof." title="Ünvan"></td><td><input name="ctl00$MainContent$GridViewMüşteri$ctl12$ctl01" type="text" value="Osmann" title="İsim"></td><td><input name="ctl00$MainContent$GridViewMüşteri$ctl12$ctl02" type="text" value="Baykuşş" title="Soyisim"></td><td><input name="ctl00$MainContent$GridViewMüşteri$ctl12$ctl03" type="text" value="0555 555 55 99" title="TelefonNo"></td><td><input name="ctl00$MainContent$GridViewMüşteri$ctl12$ctl04" type="text" value="osmanbaykus@outlast.com" title="ePosta"></td><th scope="row"><input name="ctl00$MainContent$GridViewMüşteri$ctl12$ctl05" type="text" value="12/18/2021 2:52:00 AM" title="GörüşmeZamanı"></th><td><a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri$ctl12$ctl06','')" style="color:Black;font-weight:bold;">Güncelle</a> <a class="btn btn-warning" href="javascript:__doPostBack('ctl00$MainContent$GridViewMüşteri','Cancel$10')" style="color:Black;font-weight:bold;">Vazgeç</a></td><td></td> </tr> </tbody></table> In this code, some columns have larger width, for example Ünvan, İsim Soyisim TelelfonNo. I wanna this th, td and inputs should take just enough space according to max length of them. Also, this is a gridview, when I use update button that I named Düzenle it's getting this shape. When I just change input's width, just they are narrowed down but columns don't. When I change th and td tag together, it has narrowed down. |
Android studio TTS: Not reading text passed into speak() function Posted: 19 Dec 2021 12:25 PM PST I'm working on an app which uses MLKit's OCR function to read text from an image, display it to the user and then use Android's TTS but it doesn't seem to be working. private TextToSpeech textReader; // Instance of Android's built in TTS private String multipleBlockText; // Empty to store multiple blocks // Initialise TTS textReader = new TextToSpeech(this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { textReader.setLanguage(Locale.UK); // Sets language to US, English. } }); // OCR code goes here @Override public void onClick(View v) { try { detectText(); // Calls function for OCR from LKit library // Reads text textReader.speak(text, TextToSpeech.QUEUE_FLUSH, null); } catch(Exception error){ // Error handling: Prevents app crash on no text readable detectedText.setText("Error!"); } } I've declared the TTS in my mannifest also: <activity android:name=".MainActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.TTS_SERVICE" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> But when I run my app, it'll display image text to the user, but TTS won't read it aloud. The OCR function works fine and text in the image is stored in the "multipleBlockText" variable. |
Type definitions for Redux (Toolkit) store with preloadedState Posted: 19 Dec 2021 12:27 PM PST I'm trying to make typings work for configuring a Redux store with a preloaded state. The Redux Toolkit TypeScript quick start guide has this example: import { configureStore } from '@reduxjs/toolkit' const store = configureStore({ reducer: { one: oneSlice.reducer, two: twoSlice.reducer } }) // Infer the `RootState` and `AppDispatch` types from the store itself export type RootState = ReturnType<typeof store.getState> export type AppDispatch = typeof store.dispatch Unfortunately with a preloaded state, it looks more like this: export function initStore(preloadedState) { const store = configureStore({ reducer: { one: oneSlice.reducer, two: twoSlice.reducer }, preloadedState, }) return store } From where do I now get the RootState type and the AppDispatch type? |
Getting pandas dataframe from list of nested dictionaries Posted: 19 Dec 2021 12:27 PM PST I am new to Python so this may be pretty straightforward, but I have not been able to find a good answer for my problem after looking for a while. I am trying to create a Pandas dataframe from a list of dictionaries. My list of nested dictionaries is the following: my_list = [{0: {'a': '23', 'b': '15', 'c': '5', 'd': '-1'}, 1: {'a': '5', 'b': '6', 'c': '7', 'd': '9'}, 2: {'a': '9', 'b': '15', 'c': '5', 'd': '7'}}, {0: {'a': '5', 'b': '249', 'c': '92', 'd': '-4'}, 1: {'a': '51', 'b': '5', 'c': '34', 'd': '1'}, 2: {'a': '3', 'b': '8', 'c': '3', 'd': '11'}}] So each key in the main dictionaries has 3 values. Putting these into a dataframe using data = pd.DataFrame(my_list) returns something unusable, as each cell has information on a, b, c and d in it. I want to end up with a dataframe that looks like this: name| a | b | c | d 0 | 23 | 15 | 5 | -1 1 | 5 | 6 | 7 | 9 2 | 9 | 15 | 5 | 7 0 | 5 |249 | 92| -4 1 |51 | 5 | 34| 1 2 | 3 | 8 | 3 | 11 Is this possible? |
How to get form data from input as variable in Flask? Posted: 19 Dec 2021 12:25 PM PST I'm working on a simple UI to start and stop games by ID. The basic HTML I have written is as follows (game_id is populated by JS): <div align="center" class="top"> <div align="left" class="game-id-input"> Game ID: <input type="text" name="game_id" id="game_id"> </div> <div align="right" class="buttons"> <form action="{{ url_for('start_game', game_id=game_id) }}" method="get"> <input type="submit" name="start" value="Start game" class="btn btn-success"></input> </form> <form action="{{ url_for('end_game', game_id=game_id) }}" method="get"> <input type="submit" name="end" value="End game" class="btn btn-danger"></input> </form> </div> </div> which looks like I also have Flask route functions defined for each of the forms: @app.route("/start_game/<game_id>") def start_game(game_id): # ... @app.route("/end_game/<game_id>") def end_game(game_id): # ... In my forms, how can I make game_id correspond to the game_id from #game_id ? Currently when I submit start and end games, I get a File Not Found error because it's just appending the literal <game_id> to the route. I'm new to web development. This should be trivial, but I don't know what to search for. Sorry in advance for such a simple question. |
Clearing contents of JFormattedTextField not working? Posted: 19 Dec 2021 12:27 PM PST I have a JFormattedTextField which accepts number of 8 digits only, but when I try to clear the textfield with backspace button it doesnt delete first character of number (same behavior with delete button too), I have to presee Esc key to delete this character each time. NumberFormat intFormat = NumberFormat.getIntegerInstance(); intFormat.setGroupingUsed(false); NumberFormatter numberFormatter = new NumberFormatter(intFormat); numberFormatter.setValueClass(Integer.class); numberFormatter.setAllowsInvalid(false); numberFormatter.setMinimum(0); numberFormatter.setMaximum(99999999); releaseNoTextField = new JFormattedTextField(numberFormatter);
what's the problem here ? - Also clearing this textfield with
releaseNoTextField.setText("") is not working, is there another way to do this ? |
Is there any way to get a DetailsView control to render its HeaderText in a <th> cell? Posted: 19 Dec 2021 12:26 PM PST As the DetailsView uses <td> cells for both the header text and the data, I was wondering whether the behaviour of the control can be overridden to render the HeaderText of each row in a <th> cell? @Joel Coehoorn Thanks for the quick reply, but I was kind of hoping I wouldn't have to go down that route. I was wondering whether it would be possible to override one of the control rendering methods to achieve this? Someone seems to have had success rendering <th> cells but did not appear to disclose details - any other suggestions would be gratefully received. |
When should I use double or single quotes in JavaScript? Posted: 19 Dec 2021 12:27 PM PST console.log("double"); vs. console.log('single'); I see more and more JavaScript libraries out there using single quotes when handling strings. What are the reasons to use one over the other? I thought they're pretty much interchangeable. |
No comments:
Post a Comment