scope

Python Kivy screen manager wiget scope

混江龙づ霸主 提交于 2019-12-12 02:12:27
问题 I am trying to control a screen manager from buttons in a separate class, but I cannot figure out what to set on the button on_press: statements. Kivy file: <HeaderSection>: anchor_x: 'center' anchor_y: 'top' BoxLayout: orientation: 'horizontal' size_hint: 1, .1 id: header Label: text: 'My App' <ContentSection>: anchor_x: 'center' anchor_y: 'center' ScreenManager: size_hint: 1, .8 Screen: name: 'home' Label: text: 'First screen' Screen: name: 'second' Label: text: 'Second screen' Screen: name

Prompt return as undefined in a function. (scope issue)

我的未来我决定 提交于 2019-12-12 02:01:32
问题 I believe it's a scope issue because I tried setting my function userPrmpt inside firstPartCook and it works. I set it outside, and it doesn't. So it's reading, but not keeping what is returned. I thought by placing it in the test var that it would work, but it doesn't. Here's my code HTML <!DOCTYPE html> <html> <head> <title> Race Makin' </title> <!-- Link to the JS portion for this script --> <script src="riceMakin.js"></script> </head> <body> <!-- not going for anything fancy. Just

use of “struct Foo” in field decl doesn't forward declare nested class

做~自己de王妃 提交于 2019-12-12 01:46:41
问题 I am apparently misunderstanding how the C-ish feature of simultaneously "declaring" and referring to a type using struct X works in C++. (Plus I don't even know what this feature is called, properly.) I have three examples below to show what I'm doing but the main question is: Why is the nested type, forward declared in this way, at global scope instead of in class scope? This works to forward declare a nested struct: #include <memory> class Foo1 { Foo1(); ~Foo1(); struct Impl; std::auto_ptr

Cannot set Angular scope variable from within ajax call

主宰稳场 提交于 2019-12-12 01:40:08
问题 var req = { "RequestId": $scope.$parent.req_id, "RequestDate": new Date(), "RequestDetails": $scope.$parent.details }; $scope.req_result = "test"; $.ajax({ type: "POST", url: 'http://localhost:49358/api/myClasses/PostRequest', data: JSON.stringify(req), contentType: "application/json;charset=utf-8", processData: true, success: function (data, status, xhr) { console.log("The result is : " + status); $scope.req_result = "Post succeeded"; }, error: function (xhr) { $scope.req_result = "ERROR: "

Undefined variable error when calling a function from another snippet

倖福魔咒の 提交于 2019-12-12 01:34:54
问题 The following PHP page <?php $a = "World"; function say() { echo $a; } ?> Hello, <?php say(); ?> fails with: Undefined variable: a in test.php on line 5 Could someone explain me why, and what is the best way to fix this? 回答1: you have to define variable as global inside the function <?php $a = "World"; function say() { global $a; echo $a; } say(); ?> 来源: https://stackoverflow.com/questions/14301958/undefined-variable-error-when-calling-a-function-from-another-snippet

Is it possible to keep an AJAX request active after user navigates to another page of the website?

本小妞迷上赌 提交于 2019-12-12 01:23:48
问题 I am having a website where a user submits a form using ajax. The response is shown in alert whether the form was successfully submitted or the details of the problem. Now since this process is asynchronous, if the user navigates to another page before the response is received, the XMLHttpRequest object that was used for submitting the form is deleted and the user does not get feedback about the status of the submitted form. So, is it possible to have the XMLHttpRequest object remain active

Why does parser generated by ANTLR reuse context objects?

﹥>﹥吖頭↗ 提交于 2019-12-12 01:19:29
问题 I'm trying to create an interpreter for a simple programming language using ANTLR. I would like to add the feature of recursion. So far I have implemented the definition and calling functions with option of using several return statements and also local variables. To achieve having local variables I extended the parser partial class of FunctionCallContext with a dictionary for them. I can successfully use them for one time. Also, when I call the same function again from itself (recursively),

How can I make a regular variable accessible in files included by a class method?

て烟熏妆下的殇ゞ 提交于 2019-12-12 01:16:28
问题 I have a php site which flows as shown below. Please note I'm leaving out most of the code (wherever theres an ellipses). index.php include template.php ... $_template = new template; $_template->load(); ... template.php class pal_template { ... public function load() { ... include example.php; ... } example.php ... global $_template; $_tempalate->foo(); ... Now, this works fine. However, I end up having a ton of files that are displayed via the $_template->load() method, and within each of

How to choose the right bean scope?

好久不见. 提交于 2019-12-12 00:26:24
问题 I noticed that there are different bean scopes like: @RequestScoped @ViewScoped @FlowScoped @SessionScoped @ApplicationScoped What is the purpose of each? How do I choose a proper scope for my bean? 回答1: Introduction It represents the scope (the lifetime) of the bean. This is easier to understand if you are familiar with "under the covers" working of a basic servlet web application: How do servlets work? Instantiation, sessions, shared variables and multithreading. @Request/View/Flow/Session

ajax and variable scope

血红的双手。 提交于 2019-12-11 23:59:52
问题 I am writing a script that reads multiple twitter feeds and writes them to a div. The code works when I am just making 1 AJAX request to a specific feed, but when I try to loop through a list of feeds, I get nothing. I'm pretty sure that variable scope is to blame here, but I don't know how to resolve it in Javascript. Here's the 1-feed version that works, slightly simplified (using jQuery by the way): function getTweets() { $.getJSON("http://api.twitter.com/1/statuses/user_timeline.json