How can I change background color Entry widget in Monodevelop GTK#? - monodevelop

I'm using Monodevelop GTK# and trying change background color in entry widget, but
entry.ModifyBase(StateType, Gdk.Color)
or
entry.ModifyBg(StateType, Gdk.Color)
don't change background color for me.
Maybe someone faced this problem and solved it.

Many times you cannot actually change anything: Gtk (and hence Gtk#) thinks it knows better than you the best style for you widgets, and that methods do not do anything.

You can specify this using the GTK RC files, assuming you are using GTK# v2 and not v3. An RC file declares styles which can be loaded into the windowing engine at runtime, when you start your app.
You can find examples of RC files on the web, however the following is an example of the sort of thing:
gtk-color-scheme = "bg_colour:#101010
fg_colour:#FFFFFF
fg_insensitive_colour:#EEEEEE
bg_prelight_colour:#38a4da
bg_selected_colour:#38a4da
gtk-auto-mnemonics = 1
gtk-primary-button-warps-slider = 1
engine "murrine"
{
contrast = 1.0
glazestyle = 1 # 0 = flat hilight, 1 = curved hilight, 2 = concave style, 3 = top curved hilight, 4 = beryl hilight
menubarstyle = 0 # 0 = flat, 1 = glassy, 2 = gradient, 3 = striped
menubaritemstyle = 1 # 0 = menuitem look, 1 = button look
menuitemstyle = 0 # 0 = flat, 1 = glassy, 2 = striped
listviewheaderstyle = 0 # 0 = flat, 1 = glassy, 2 = raised
listviewstyle = 0 # 0 = nothing, 1 = dotted
scrollbarstyle = 0 # 0 = nothing, 1 = circles, 2 = handles, 3 = diagonal stripes, 4 = diagonal stripes and handles, 5 = horizontal stripes, 6 = horizontal stripes and handles
highlight_shade = 0.9555 # set the amount of buttons or widgets hilight
roundness = 2 # 0 = squared, 1 = old default, more will increase roundness
reliefstyle = 2 # 0 = flat, 1 = inset, 2 = shadow, 3 = gradient shadow, 4 = strong shadow
lightborderstyle = 1 # 0 = on top, 1 = on all sides
animation = FALSE # FALSE = disabled, TRUE = enabled
gradients = TRUE
glow_shade = 1.0
comboboxstyle = 0 # 1 to colourize below button
expanderstyle = 0 # 0 = arrows, 1 = circles, 2 = buttons
}
style "entry"
{
xthickness = 3
ythickness = 4
base[ACTIVE] = #bg_colour
base[INSENSITIVE] = #bg_colour
base[NORMAL] = #bg_colour
base[PRELIGHT] = #bg_prelight_colour
base[SELECTED] = #bg_selected_colour
bg[ACTIVE] = #bg_colour
bg[INSENSITIVE] = #bg_colour
bg[NORMAL] = #bg_colour
bg[PRELIGHT] = #bg_colour
bg[SELECTED] = #bg_colour
fg[ACTIVE] = #fg_colour
fg[INSENSITIVE] = #fg_insensitive_colour
fg[NORMAL] = #fg_colour
fg[PRELIGHT] = #fg_colour
fg[SELECTED] = #fg_colour
text[ACTIVE] = #fg_colour
text[INSENSITIVE] = #fg_insensitive_colour
text[NORMAL] = #fg_colour
text[PRELIGHT] = #fg_colour
text[SELECTED] = #fg_colour
}
class "GtkEntry" style "entry"
"
The C# you need to load your file is as follows, which will need to be called somewhere in your Program static main (). This assumes your GTKRC is an embedded resource inside an assembly in your project:
var _a = Assembly.GetAssembly (typeof (<your class>));
using (var _s = _a.GetManifestResourceStream ("<path in class's assembly to GTKRC file>")) {
using (StreamReader _r = new StreamReader (_s)) {
string _rc = _r.ReadToEnd ();
Gtk.Rc.ParseString (_rc);
Gtk.Settings.Default.ThemeName = "<your theme name>";
}
}

Related

How do i get a tkinter Entry, which is inside a function and run it through another function?

#After clicking the button_next, nothing happens, the interface dosnt change at all
#After i clicked the button_next i would like the text to change which includes the input_name Entry()
def stage_0():
label_welcome = Label(text= "Welcome to Calorie counter", font =("Arial",24,"bold"),fg = "blue", bg ="#FFFF00")
label_welcome.pack(side = "top")
label_name=Label(text ="What is your name?",font = 18, bg ="#FFFF00")
label_name.pack()
input_name = Entry()
input_name.pack()
button_next = Button(text = "next",font = 18,command = name_input)
button_next.pack()
def name_input():
name = input_name.get()
print(name)
if name.isalpha()== True:
label_welcome["text"]= f"Nice to meet you {input_name.get()}!"
button_next.pack_forget()
input_name.pack_forget()
label_name["text"] ="What is your age"
scale_age = Scale(from_=0, to=100, orient = HORIZONTAL)
scale_age.pack()
else:
label_welcome["text"]= "Only alphabets allowed. Please try again"

Is it possible to arrange graphs and filters in an R plot output?

I have created a small dashboard using bscols( from the crosstalkpackage. It consists of plotly graphs and their respective filter_checkboxes.
It looks pretty messy now, as the filters are not vertically aligned with their corresponding plots.
HTML_graphic
As indicated, I would like the first two checkbox sets to appear next to the second line graph (nothing to appear next to the first line graph); and the second two checkbox sets to appear next to the third line graph.
Also, I would like to create some vertical space between the three elements, as indicated by the brown and black horizontal lines.
The best solution would be to set the height of the html elements inside the bscols() command. Because in the future, I would like to programmatically save multiple of these outputs using htmltools::save_html.
The next best would be to have the output of that command somehow converted to html and add html code like line breaks or heights.
Neither I know how to do.
I came across this related question but it is unanswered: Arrange crosstalk graphs via bscols
Any suggestions on how to solve my problem?
My code
{r 002_Auto App Doc Vol_Invoice group delta plot - plot code, echo = FALSE}
# Setup of the legend for invoice plot
invoice_plot_legend <- list(
font = list(
family = "sans-serif",
size = 12,
color = "#000"),
title = list(text="<b> Delta previous month by division </b>"),
bgcolor = "#E2E2E2",
bordercolor = "#FFFFFF",
borderwidth = 2,
layout.legend = "constant",
traceorder = "grouped")
# The Shared Data format is needed for crosstalk to be able to filter the dataset upon clicking the checkboxes (division filters):
shared_invoice <- SharedData$new(Auto_App_Doc_Vol_invoiceg_plotting_tibble)
shared_invoice_KPI <- SharedData$new(Auto_App_Doc_Vol_KPI)
shared_abs <- SharedData$new(Auto_App_Doc_Vol_plotting_tibble_diff_abs)
# Setup of a bscols html widget; widths determines the widths of the input lists (here, 2: the filters, 10: the plot and legend)
# Overall KPI and invoice group plot
library(htmlwidgets)
crosstalk::bscols(
widths = c(2, 10),
list(
crosstalk::filter_checkbox("Division",
label = "Division",
sharedData = shared_invoice,
group = ~Division),
crosstalk::filter_checkbox("Rechnungsgruppe",
label = "Invoice group",
sharedData = shared_invoice,
group = ~Rechnungsgruppe),
crosstalk::filter_checkbox("Rechnungsgruppe",
label = "Invoice group",
sharedData = shared_abs,
group = ~Rechnungsgruppe),
crosstalk::filter_checkbox("Division",
label = "Division",
sharedData = shared_abs,
group = ~Division)
)
,
list(
plot_ly(data = shared_invoice_KPI, x = ~Freigabedatum_REAL_YM, y = ~KPI_current_month, meta = ~Division,
type = "scatter",
mode = "lines+text",
text = ~KPI_current_month,
textposition='top center',
hovertemplate = "%{meta}",
color = ~Diff_KPI_pp)
%>%
layout(legend = invoice_plot_legend,
title = "Automatically Approved Document Volume",
xaxis = list(title = 'Release date'),
yaxis = list(title = '%'))
,
plot_ly(data = shared_invoice, x = ~Freigabedatum_REAL_YM, y = ~n,
type = "scatter",
mode = "lines",
text = ~Rechnungsgruppe_effort,
hoverinfo = "y+text",
color = ~Difference_inline
)
%>%
layout(legend = invoice_plot_legend,
title = " ",
xaxis = list(title = 'Release date'),
yaxis = list(title = '# of Approved Documents'))
,
plot_ly(data = shared_abs, x = ~Freigabedatum_REAL_YM, y = ~n,
type = "scatter",
mode = "lines",
text = ~Lieferantenname,
hoverinfo = "y+text",
color = ~Lieferantenname_text
)
%>%
layout(legend = vendor_plot_legend,
title = "by vendor absolute delta previous month all documents",
xaxis = list(title = 'Release date'),
yaxis = list(title = '# of Approved Documents w/ & w/o effort')
)
)
)
Thank you so much!

2D heatmap from x,y data / Octave

I am trying to create 2D heatmap from those two parameters:
diffQ = discharge(2:lgth) - discharge(1:lgth-1);
difft = time(2:lgth) - time(1:lgth-1);
My former colleague made code for just one parameter:
diff = discharge(2:lgth) - discharge(1:lgth-1);
bin = 1;
idiff = int32(diff);
mx = max(idiff);
mn = min(idiff);
msh = ones(((mx-mn)/bin)+2);
for i = 1:lgth-2
y = ((idiff(i)-mn)/bin)+1;
x = (((idiff(i+1)-mn)/bin)+1);
msh(x,y) = msh(x,y) + 1;
end
mshl = log(log(log(msh)+1)+1);
newplot();
surface(mshl,'EdgeColor','none');
colormap(heatMapA);
but I can't figure out how to change plot creating for my case.
Thanks a lot
Kozina

Octave function terminates inexplicably

I am implementing an interpolating function using Octave, and I have the following in a Sublime text file:
function root = HermiteInterp(x, y, yp)
Q = zeros(2*length(x), 2*length(x));
disp(Q);
z = zeros(1, 2*length(x));
new_y = zeros(1, 2*length(x));
for i = 1:length(x)
z((2*i)-1) = x(i);
z(2*i) = x(i);
new_y((2*i)-1) = y(i);
new_y(2*i) = y(i);
y_prime(2*i) = yp(i);
end
y_transpose = transpose(new_y);
disp(y_transpose);
yp_transpose = transpose(y_prime);
append_to_Q = [y_transpose, Q];
disp('test1');
disp('test2');
Yet the function never makes it to the display statement. What's causing this?
Use arrow keys to scroll up and down the GUI.

Delphi / MySql : Problems escaping strings

N00b here, having problems escaping strings. I used the QuotedStr() function - shouldn't that be enough.
Unfortunately, the string that I am trying to quote is rather messy, but I will post it here in case anyone wants to paste it into WinMerge or KDiff3, etc.
I am trying to store an entire Delphi form into the database, rather than into a .DFM file. It has only one field, a TEdit edit box.
The debugger shows the form as text as
'object Form1: TScriptForm'#$D#$A' Left = 0'#$D#$A' Top = 0'#$D#$A' Align = alClient'#$D#$A' BorderStyle = bsNone'#$D#$A' ClientHeight = 517'#$D#$A' ClientWidth = 993'#$D#$A' Color = clBtnFace'#$D#$A' Font.Charset = DEFAULT_CHARSET'#$D#$A' Font.Color = clWindowText'#$D#$A' Font.Height = -11'#$D#$A' Font.Name = 'MS Sans Serif''#$D#$A' Font.Style = []'#$D#$A' OldCreateOrder = False'#$D#$A' SaveProps.Strings = ('#$D#$A' 'Visible=False')'#$D#$A' PixelsPerInch = 96'#$D#$A' TextHeight = 13'#$D#$A' object Edit1: TEdit'#$D#$A' Left = 192'#$D#$A' Top = 64'#$D#$A' Width = 121'#$D#$A' Height = 21'#$D#$A' TabOrder = 8'#$D#$A' end'#$D#$A'end'#$D#$A
before calling QuotedStr() and
''object Form1: TScriptForm'#$D#$A' Left = 0'#$D#$A' Top = 0'#$D#$A' Align = alClient'#$D#$A' BorderStyle = bsNone'#$D#$A' ClientHeight = 517'#$D#$A' ClientWidth = 993'#$D#$A' Color = clBtnFace'#$D#$A' Font.Charset = DEFAULT_CHARSET'#$D#$A' Font.Color = clWindowText'#$D#$A' Font.Height = -11'#$D#$A' Font.Name = ''MS Sans Serif'''#$D#$A' Font.Style = []'#$D#$A' OldCreateOrder = False'#$D#$A' SaveProps.Strings = ('#$D#$A' ''Visible=False'')'#$D#$A' PixelsPerInch = 96'#$D#$A' TextHeight = 13'#$D#$A' object Edit1: TEdit'#$D#$A' Left = 192'#$D#$A' Top = 64'#$D#$A' Width = 121'#$D#$A' Height = 21'#$D#$A' TabOrder = 8'#$D#$A' end'#$D#$A'end'#$D#$A'''
afterwards.
The strange thing is that my complete command
'INSERT INTO designerFormDfm(designerFormDfmText) VALUES ("'object Form1: TScriptForm'#$D#$A' Left = 0'#$D#$A' Top = 0'#$D#$A' Align = alClient'#$D#$A' BorderStyle = bsNone'#$D#$A' ClientHeight = 517'#$D#$A' ClientWidth = 993'#$D#$A' Color = clBtnFace'#$D#$A' Font.Charset = DEFAULT_CHARSET'#$D#$A' Font.Color = clWindowText'#$D#$A' Font.Height = -11'#$D#$A' Font.Name = ''MS Sans Serif'''#$D#$A' Font.Style = []'#$D#$A' OldCreateOrder = False'#$D#$A' SaveProps.Strings = ('#$D#$A' ''Visible=False'')'#$D#$A' PixelsPerInch = 96'#$D#$A' TextHeight = 13'#$D#$A' object Edit1: TEdit'#$D#$A' Left = 192'#$D#$A' Top = 64'#$D#$A' Width = 121'#$D#$A' Height = 21'#$D#$A' TabOrder = 8'#$D#$A' end'#$D#$A'end'#$D#$A''");'
executes in a MySql console, but not from Delphi, where I pass that command as parameter command to a function which
ADOCommand.CommandText := command;
ADOCommand.CommandType := cmdText;
ADOCommand.Execute();
I can only assume that I am having problems escpaing sequences which contain single quotes (and QuotedStr() doesn't seem to escape backslahes(?!))
What am I doing that is obviously, glaringly wrong?
#mawg, the #da-soft suggestion is ok , the best way to interact with inserts and updates is using parameters.
check this sample
var
ADOCommand : TADOCommand;
begin
ADOCommand:=TADOCommand.Create(nil);
try
ADOCommand.Connection:=AdoConnection;
ADOCommand.Parameters.Clear;
ADOCommand.CommandText:='INSERT INTO designerFormDfm (designerFormDfmText) VALUES (:designerFormDfmText)';
ADOCommand.ParamCheck:=False;
ADOCommand.Parameters.ParamByName('designerFormDfmText').Value:= YourData;
ADOCommand.Execute;
finally
ADOCommand.Free;
end;
end;
The short answer - use the parameterized query !